From 3b7a7462a2fe3d71a321860ac111b60b76bf44dd Mon Sep 17 00:00:00 2001 From: emersion Date: Fri, 18 Jan 2019 19:32:06 +0100 Subject: [PATCH] Fix crash in cursor_rebase with multiple screens Designing the output configuration sequence without invalid state is tricky. We have one function, apply_output_config, that takes an output and (besides other things) performs a modeset and inserts the output in the output layout. The modeset can fail, in which case we don't want the output to be enabled. We also have an output_enable function, which calls output_apply_config and also configures the output's workspace and inserts it in the root container. Now, we have two choices. Either we configure the output before it's been inserted in the root container and then, if the modeset was successful, we insert it and create the workspace. The main issue with this approach is that configuring the output triggers a handful of signals, namely wlr_output.mode and wlr_output_layout.change. In those event handlers, we need to make sure to ignore these outputs in the process of being configured. Either we first insert the output, create the workspace and then try to configure it. It means we need to undo everything if the modeset fails. The main issue with this solution is that it enables and disables the output very quickly, creates a workspace and immediately destroys it, and maybe moves views back and forth (see output_evacuate). I've tried to make it so an output isn't enabled then immediately disabled. We already have code for ignoring outputs when the output is being destructed. Fixes https://github.com/swaywm/sway/issues/3462 --- sway/input/cursor.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sway/input/cursor.c b/sway/input/cursor.c index 5eb44412..35683f06 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c @@ -83,8 +83,8 @@ struct sway_node *node_at_coords( return NULL; } struct sway_output *output = wlr_output->data; - if (!output) { - // output is being destroyed + if (!output || !output->configured) { + // output is being destroyed or is being configured return NULL; } double ox = lx, oy = ly;