diff options
author | Drew DeVault <sir@cmpwn.com> | 2015-12-03 08:35:22 -0500 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2015-12-03 08:35:22 -0500 |
commit | 71afa388906bf29dcd937aa92b65a97c8b320f60 (patch) | |
tree | 7e7efa0fccde6eb99b1b1bd9d20b1d0f1b2b5f3b | |
parent | Revert "Remove build badge (Travis is broken, not sway)" (diff) | |
download | sway-71afa388906bf29dcd937aa92b65a97c8b320f60.tar.gz sway-71afa388906bf29dcd937aa92b65a97c8b320f60.tar.zst sway-71afa388906bf29dcd937aa92b65a97c8b320f60.zip |
Add swaylock protocol, add resource destructors
This prevents sway crashing if swaybg or swaybar dies.
-rw-r--r-- | common/libsway-common.a | bin | 0 -> 59254 bytes | |||
-rw-r--r-- | include/extensions.h | 11 | ||||
-rw-r--r-- | protocols/CMakeLists.txt | 11 | ||||
-rw-r--r-- | protocols/libsway-protocols.a | bin | 0 -> 31798 bytes | |||
-rw-r--r-- | protocols/swaylock.xml | 18 | ||||
-rw-r--r-- | sway/extensions.c | 29 | ||||
-rw-r--r-- | wayland/libsway-wayland.a | bin | 0 -> 70060 bytes |
7 files changed, 68 insertions, 1 deletions
diff --git a/common/libsway-common.a b/common/libsway-common.a new file mode 100644 index 00000000..22267800 --- /dev/null +++ b/common/libsway-common.a | |||
Binary files differ | |||
diff --git a/include/extensions.h b/include/extensions.h index 1ef7d920..872fd3bd 100644 --- a/include/extensions.h +++ b/include/extensions.h | |||
@@ -1,18 +1,21 @@ | |||
1 | #ifndef _SWAY_EXTENSIONS_H | 1 | #ifndef _SWAY_EXTENSIONS_H |
2 | #define _SWAY_EXTENSIONS_H | 2 | #define _SWAY_EXTENSIONS_H |
3 | 3 | ||
4 | #include <wayland-server-core.h> | ||
5 | #include <wlc/wlc-wayland.h> | ||
4 | #include "wayland-desktop-shell-server-protocol.h" | 6 | #include "wayland-desktop-shell-server-protocol.h" |
5 | #include "list.h" | 7 | #include "list.h" |
6 | #include "wlc/wlc-wayland.h" | ||
7 | 8 | ||
8 | struct background_config { | 9 | struct background_config { |
9 | wlc_handle output; | 10 | wlc_handle output; |
10 | wlc_resource surface; | 11 | wlc_resource surface; |
12 | struct wl_resource *resource; | ||
11 | }; | 13 | }; |
12 | 14 | ||
13 | struct panel_config { | 15 | struct panel_config { |
14 | wlc_handle output; | 16 | wlc_handle output; |
15 | wlc_resource surface; | 17 | wlc_resource surface; |
18 | struct wl_resource *resource; | ||
16 | }; | 19 | }; |
17 | 20 | ||
18 | struct desktop_shell_state { | 21 | struct desktop_shell_state { |
@@ -22,6 +25,12 @@ struct desktop_shell_state { | |||
22 | struct wlc_size panel_size; | 25 | struct wlc_size panel_size; |
23 | }; | 26 | }; |
24 | 27 | ||
28 | struct swaylock_state { | ||
29 | bool active; | ||
30 | wlc_handle output; | ||
31 | wlc_resource surface; | ||
32 | }; | ||
33 | |||
25 | extern struct desktop_shell_state desktop_shell; | 34 | extern struct desktop_shell_state desktop_shell; |
26 | 35 | ||
27 | void register_extensions(void); | 36 | void register_extensions(void); |
diff --git a/protocols/CMakeLists.txt b/protocols/CMakeLists.txt index 07becc36..d7516d0c 100644 --- a/protocols/CMakeLists.txt +++ b/protocols/CMakeLists.txt | |||
@@ -13,10 +13,21 @@ WAYLAND_ADD_PROTOCOL_SERVER(proto-server-desktop-shell | |||
13 | desktop-shell | 13 | desktop-shell |
14 | ) | 14 | ) |
15 | 15 | ||
16 | WAYLAND_ADD_PROTOCOL_CLIENT(proto-client-swaylock | ||
17 | swaylock.xml | ||
18 | swaylock | ||
19 | ) | ||
20 | WAYLAND_ADD_PROTOCOL_SERVER(proto-server-swaylock | ||
21 | swaylock.xml | ||
22 | swaylock | ||
23 | ) | ||
24 | |||
16 | add_library(sway-protocols | 25 | add_library(sway-protocols |
17 | ${proto-client-xdg-shell} | 26 | ${proto-client-xdg-shell} |
18 | ${proto-client-desktop-shell} | 27 | ${proto-client-desktop-shell} |
19 | ${proto-server-desktop-shell} | 28 | ${proto-server-desktop-shell} |
29 | ${proto-client-swaylock} | ||
30 | ${proto-server-swaylock} | ||
20 | ) | 31 | ) |
21 | 32 | ||
22 | set(PROTOCOLS_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/protocols PARENT_SCOPE) | 33 | set(PROTOCOLS_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/protocols PARENT_SCOPE) |
diff --git a/protocols/libsway-protocols.a b/protocols/libsway-protocols.a new file mode 100644 index 00000000..284f46c2 --- /dev/null +++ b/protocols/libsway-protocols.a | |||
Binary files differ | |||
diff --git a/protocols/swaylock.xml b/protocols/swaylock.xml new file mode 100644 index 00000000..c7a102dd --- /dev/null +++ b/protocols/swaylock.xml | |||
@@ -0,0 +1,18 @@ | |||
1 | <protocol name="lock"> | ||
2 | |||
3 | <interface name="lock" version="1"> | ||
4 | <description summary="create lock screen UIs"> | ||
5 | The Weston desktop-shell protocol's locking functionality depends more | ||
6 | on the behavior of the compositor than of a screen locking client, so | ||
7 | another protocol is necessary. | ||
8 | </description> | ||
9 | |||
10 | <request name="set_lock_surface"> | ||
11 | <arg name="output" type="object" interface="wl_output"/> | ||
12 | <arg name="surface" type="object" interface="wl_surface"/> | ||
13 | </request> | ||
14 | |||
15 | <request name="unlock"/> | ||
16 | |||
17 | </interface> | ||
18 | </protocol> | ||
diff --git a/sway/extensions.c b/sway/extensions.c index 1f8e9a7c..18621015 100644 --- a/sway/extensions.c +++ b/sway/extensions.c | |||
@@ -8,6 +8,31 @@ | |||
8 | 8 | ||
9 | struct desktop_shell_state desktop_shell; | 9 | struct desktop_shell_state desktop_shell; |
10 | 10 | ||
11 | void background_surface_destructor(struct wl_resource *resource) { | ||
12 | sway_log(L_DEBUG, "Background surface killed"); | ||
13 | int i; | ||
14 | for (i = 0; i < desktop_shell.backgrounds->length; ++i) { | ||
15 | struct background_config *config = desktop_shell.backgrounds->items[i]; | ||
16 | if (config->resource == resource) { | ||
17 | list_del(desktop_shell.backgrounds, i); | ||
18 | break; | ||
19 | } | ||
20 | } | ||
21 | } | ||
22 | |||
23 | void panel_surface_destructor(struct wl_resource *resource) { | ||
24 | sway_log(L_DEBUG, "Panel surface killed"); | ||
25 | int i; | ||
26 | for (i = 0; i < desktop_shell.panels->length; ++i) { | ||
27 | struct panel_config *config = desktop_shell.panels->items[i]; | ||
28 | if (config->resource == resource) { | ||
29 | list_del(desktop_shell.panels, i); | ||
30 | arrange_windows(&root_container, -1, -1); | ||
31 | break; | ||
32 | } | ||
33 | } | ||
34 | } | ||
35 | |||
11 | static void set_background(struct wl_client *client, struct wl_resource *resource, | 36 | static void set_background(struct wl_client *client, struct wl_resource *resource, |
12 | struct wl_resource *_output, struct wl_resource *surface) { | 37 | struct wl_resource *_output, struct wl_resource *surface) { |
13 | wlc_handle output = wlc_handle_from_wl_output_resource(_output); | 38 | wlc_handle output = wlc_handle_from_wl_output_resource(_output); |
@@ -18,7 +43,9 @@ static void set_background(struct wl_client *client, struct wl_resource *resourc | |||
18 | struct background_config *config = malloc(sizeof(struct background_config)); | 43 | struct background_config *config = malloc(sizeof(struct background_config)); |
19 | config->output = output; | 44 | config->output = output; |
20 | config->surface = wlc_resource_from_wl_surface_resource(surface); | 45 | config->surface = wlc_resource_from_wl_surface_resource(surface); |
46 | config->resource = surface; | ||
21 | list_add(desktop_shell.backgrounds, config); | 47 | list_add(desktop_shell.backgrounds, config); |
48 | wl_resource_set_destructor(surface, background_surface_destructor); | ||
22 | } | 49 | } |
23 | 50 | ||
24 | static void set_panel(struct wl_client *client, struct wl_resource *resource, | 51 | static void set_panel(struct wl_client *client, struct wl_resource *resource, |
@@ -31,7 +58,9 @@ static void set_panel(struct wl_client *client, struct wl_resource *resource, | |||
31 | struct panel_config *config = malloc(sizeof(struct panel_config)); | 58 | struct panel_config *config = malloc(sizeof(struct panel_config)); |
32 | config->output = output; | 59 | config->output = output; |
33 | config->surface = wlc_resource_from_wl_surface_resource(surface); | 60 | config->surface = wlc_resource_from_wl_surface_resource(surface); |
61 | config->resource = surface; | ||
34 | list_add(desktop_shell.panels, config); | 62 | list_add(desktop_shell.panels, config); |
63 | wl_resource_set_destructor(surface, panel_surface_destructor); | ||
35 | desktop_shell.panel_size = *wlc_surface_get_size(config->surface); | 64 | desktop_shell.panel_size = *wlc_surface_get_size(config->surface); |
36 | arrange_windows(&root_container, -1, -1); | 65 | arrange_windows(&root_container, -1, -1); |
37 | } | 66 | } |
diff --git a/wayland/libsway-wayland.a b/wayland/libsway-wayland.a new file mode 100644 index 00000000..ac0f682c --- /dev/null +++ b/wayland/libsway-wayland.a | |||
Binary files differ | |||