From b1bd0e2557ad7b151fa10a6735f9f14ca3b3a368 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Mon, 23 Apr 2018 16:16:47 +0200 Subject: [PATCH 1/2] layer-shell: Fix crash when cursor is intially outside any output On the X11 backend the cursor position might be outside the output window so no output is returned leading to the assert to trigger. Use sane fallback instead of crashing. --- rootston/layer_shell.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/rootston/layer_shell.c b/rootston/layer_shell.c index 836deb42..db0aeb59 100644 --- a/rootston/layer_shell.c +++ b/rootston/layer_shell.c @@ -395,8 +395,18 @@ void handle_layer_shell_surface(struct wl_listener *listener, void *data) { wlr_output_layout_output_at(desktop->layout, seat->cursor->cursor->x, seat->cursor->cursor->y); - assert(output); // And this one - layer_surface->output = output; + if (!output) { + wlr_log(L_ERROR, "Couldn't find output at (%.0f,%.0f)", + seat->cursor->cursor->x, + seat->cursor->cursor->y); + output = wlr_output_layout_get_center_output(desktop->layout); + } + if (output) { + layer_surface->output = output; + } else { + wlr_layer_surface_close(layer_surface); + return; + } } roots_surface->surface_commit.notify = handle_surface_commit; From d81f0170a323d64b17461bfba5fd6e437e44dd89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Thu, 26 Apr 2018 14:04:24 +0200 Subject: [PATCH 2/2] layer-shell: Don't crash when the compositor didn't find a suitable output In that case it must have closed the surface. --- types/wlr_layer_shell.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/types/wlr_layer_shell.c b/types/wlr_layer_shell.c index c61556bf..61ab5c14 100644 --- a/types/wlr_layer_shell.c +++ b/types/wlr_layer_shell.c @@ -287,7 +287,9 @@ static void handle_wlr_surface_committed(struct wlr_surface *wlr_surface, surface->added = true; wlr_signal_emit_safe(&surface->shell->events.new_surface, surface); - assert(surface->output); + // either the compositor found a suitable output or it must + // have closed the surface + assert(surface->output || surface->closed); } if (surface->configured && wlr_surface_has_buffer(surface->surface) && !surface->mapped) {