aboutsummaryrefslogtreecommitdiffstats
path: root/sway
diff options
context:
space:
mode:
authorLibravatar db <github@benedik.si>2018-05-01 17:38:55 +0200
committerLibravatar db <github@benedik.si>2018-05-01 19:05:32 +0200
commit22170bde77a92126ab5c183604634bbb2b89a10a (patch)
tree926b0553f47eb786dc0c40ab99d2d56ebc64c66b /sway
parentMerge pull request #1874 from RyanDwyer/borders (diff)
downloadsway-22170bde77a92126ab5c183604634bbb2b89a10a.tar.gz
sway-22170bde77a92126ab5c183604634bbb2b89a10a.tar.zst
sway-22170bde77a92126ab5c183604634bbb2b89a10a.zip
Fix layer surface crash on output destroy
Before freeing sway_output, NULL the wlr_output reference to it. Check for that NULL in layer_shell handle_destroy. Don't damage null container in unmap. Additionaly, terminate swaybg if its output is being disabled.
Diffstat (limited to 'sway')
-rw-r--r--sway/config/output.c4
-rw-r--r--sway/desktop/layer_shell.c9
-rw-r--r--sway/tree/container.c3
3 files changed, 14 insertions, 2 deletions
diff --git a/sway/config/output.c b/sway/config/output.c
index 1c298d37..68022278 100644
--- a/sway/config/output.c
+++ b/sway/config/output.c
@@ -128,6 +128,10 @@ void apply_output_config(struct output_config *oc, struct sway_container *output
128 struct wlr_output *wlr_output = output->sway_output->wlr_output; 128 struct wlr_output *wlr_output = output->sway_output->wlr_output;
129 129
130 if (oc && oc->enabled == 0) { 130 if (oc && oc->enabled == 0) {
131 if (output->sway_output->bg_pid != 0) {
132 terminate_swaybg(output->sway_output->bg_pid);
133 output->sway_output->bg_pid = 0;
134 }
131 container_destroy(output); 135 container_destroy(output);
132 wlr_output_layout_remove(root_container.sway_root->output_layout, 136 wlr_output_layout_remove(root_container.sway_root->output_layout,
133 wlr_output); 137 wlr_output);
diff --git a/sway/desktop/layer_shell.c b/sway/desktop/layer_shell.c
index 03419ac1..c904880d 100644
--- a/sway/desktop/layer_shell.c
+++ b/sway/desktop/layer_shell.c
@@ -255,6 +255,9 @@ static void unmap(struct sway_layer_surface *sway_layer) {
255 return; 255 return;
256 } 256 }
257 struct sway_output *output = wlr_output->data; 257 struct sway_output *output = wlr_output->data;
258 if (output == NULL) {
259 return;
260 }
258 output_damage_surface(output, sway_layer->geo.x, sway_layer->geo.y, 261 output_damage_surface(output, sway_layer->geo.x, sway_layer->geo.y,
259 sway_layer->layer_surface->surface, true); 262 sway_layer->layer_surface->surface, true);
260} 263}
@@ -274,9 +277,11 @@ static void handle_destroy(struct wl_listener *listener, void *data) {
274 wl_list_remove(&sway_layer->surface_commit.link); 277 wl_list_remove(&sway_layer->surface_commit.link);
275 if (sway_layer->layer_surface->output != NULL) { 278 if (sway_layer->layer_surface->output != NULL) {
276 struct sway_output *output = sway_layer->layer_surface->output->data; 279 struct sway_output *output = sway_layer->layer_surface->output->data;
277 arrange_layers(output); 280 if (output != NULL) {
278 281 arrange_layers(output);
282 }
279 wl_list_remove(&sway_layer->output_destroy.link); 283 wl_list_remove(&sway_layer->output_destroy.link);
284 sway_layer->layer_surface->output = NULL;
280 } 285 }
281 free(sway_layer); 286 free(sway_layer);
282} 287}
diff --git a/sway/tree/container.c b/sway/tree/container.c
index 995da5ce..6ac59547 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -156,6 +156,9 @@ static struct sway_container *container_output_destroy(
156 wl_list_remove(&output->sway_output->damage_destroy.link); 156 wl_list_remove(&output->sway_output->damage_destroy.link);
157 wl_list_remove(&output->sway_output->damage_frame.link); 157 wl_list_remove(&output->sway_output->damage_frame.link);
158 158
159 // clear the wlr_output reference to this container
160 output->sway_output->wlr_output->data = NULL;
161
159 wlr_log(L_DEBUG, "OUTPUT: Destroying output '%s'", output->name); 162 wlr_log(L_DEBUG, "OUTPUT: Destroying output '%s'", output->name);
160 _container_destroy(output); 163 _container_destroy(output);
161 return &root_container; 164 return &root_container;