sway-patched-tray-menu/sway/desktop
Thomas Hebb d726e50643 layer_shell: keep output non-NULL wherever possible
Our layer shell implementation assigns every layer surface to an output
on creation. It tracks this output using the output field on the
underlying wlr_layer_surface_v1 structure. As such, much of the existing
code assumes that output is always non-NULL and omits NULL checks
accordingly.

However, there are currently two cases where we destroy a
sway_layer_surface and output is NULL. The first is when we can't find
an output to assign the surface to and destroy it immediately after
creation. The second is when we destroy a surface in response to its
output getting destroyed, as we set output to NULL in
handle_output_destroy() before we call wlr_layer_surface_v1_destroy(),
which is what calls the appropriate unmap and destroy callbacks.

The former case doesn't cause any problems, since we haven't even
allocated a sway_layer_surface at that point or registered any
callbacks. The latter case, however, currently triggers a crash (#6120)
if a popup is visible, since our popup_handle_unmap() implementation
can't handle a NULL output.

To fix this issue, keep output set until right before we free the
sway_layer_surface. All we need to do is remove some of the cleanup
logic from handle_output_destroy(), since as of commit c9060bcc12
("layer-shell: replace close() with destroy()") that same logic is
guaranteed to be happen later when wlroots calls handle_destroy() as
part of wlr_layer_surface_v1_destroy().

This lets us remove some NULL checks from other unmap/destroy callbacks,
which is nice. We also don't need to check that the wlr_output points to
a valid sway_output anymore, since we unset that pointer after disabling
the output as of commit a0bbe67076 ("Address emersions comments on
output re-enabling") Just to be safe, I've added assertions that the
wlr_output is non-NULL wherever we use it.

Fixes #6120.
2022-04-13 10:05:24 +02:00
..
desktop.c chore: chase wlr_output_layout_get_box() update 2022-01-31 11:44:03 +01:00
idle_inhibit_v1.c idle_inhibit: Fix tree view after changes in commit 152a559e 2021-10-04 16:25:35 +02:00
layer_shell.c layer_shell: keep output non-NULL wherever possible 2022-04-13 10:05:24 +02:00
output.c chore: chase wlr_output_layout_get_box() update 2022-01-31 11:44:03 +01:00
render.c Upgrade for wlroots surface refactoring 2022-01-13 14:01:37 +03:00
surface.c Upgrade for wlroots surface refactoring 2022-01-13 14:01:37 +03:00
transaction.c transaction: destroying nodes aren't hidden 2022-01-18 19:42:15 +01:00
xdg_shell.c Don't enter seatop_move_floating when fullscreen 2022-02-24 12:12:12 +01:00
xwayland.c Don't enter seatop_move_floating when fullscreen 2022-02-24 12:12:12 +01:00