aboutsummaryrefslogtreecommitdiffstats
path: root/sway/input/cursor.c
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <bosrsf04@gmail.com>2019-01-10 03:07:36 -0500
committerLibravatar Brian Ashworth <bosrsf04@gmail.com>2019-01-10 03:07:36 -0500
commit8fd3f32c79c4784d846e05f5d9b4f284cd10ae2e (patch)
treee15d1e5a343750dc48c1055e55472641b5fda487 /sway/input/cursor.c
parentReset container dimensions when moving into workspace from direction (diff)
downloadsway-8fd3f32c79c4784d846e05f5d9b4f284cd10ae2e.tar.gz
sway-8fd3f32c79c4784d846e05f5d9b4f284cd10ae2e.tar.zst
sway-8fd3f32c79c4784d846e05f5d9b4f284cd10ae2e.zip
Fix segfaults on output destruction
This fixes two causes of segfaulting when an output is destroyed. The first occurred when an output was never enabled. The issue was that the destroy signal was never initialized so when it was emitted, sway segfaulted. This was fixed by moving the initialization into `output_create` since all outputs, regardless of whether they have ever been enabled, will be destroyed at some point. The second occurred when the cursor was on an output that was being destroyed. The sway output would have already been removed, but if there are other outputs, a cursor rebase would still occur. Since the wlr_output still existed and the sway output was destroyed, the cursor could be over nothing, resulting in a segfault when trying to get the sway output, which was destroyed.
Diffstat (limited to 'sway/input/cursor.c')
-rw-r--r--sway/input/cursor.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index 96feb47d..8f44eeae 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -85,6 +85,10 @@ static struct sway_node *node_at_coords(
85 return NULL; 85 return NULL;
86 } 86 }
87 struct sway_output *output = wlr_output->data; 87 struct sway_output *output = wlr_output->data;
88 if (!output) {
89 // output is being destroyed
90 return NULL;
91 }
88 double ox = lx, oy = ly; 92 double ox = lx, oy = ly;
89 wlr_output_layout_output_coords(root->output_layout, wlr_output, &ox, &oy); 93 wlr_output_layout_output_coords(root->output_layout, wlr_output, &ox, &oy);
90 94