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 /sway/extensions.c | |
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.
Diffstat (limited to 'sway/extensions.c')
-rw-r--r-- | sway/extensions.c | 29 |
1 files changed, 29 insertions, 0 deletions
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 | } |