sway-patched-tray-menu/sway
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
..
commands Shuffle variables to satisfy -Werror=restrict 2022-04-09 18:27:57 +02:00
config chore: chase wlr_output_layout_get_box() update 2022-01-31 11:44:03 +01:00
desktop layer_shell: keep output non-NULL wherever possible 2022-04-13 10:05:24 +02:00
input sway/input: wlr_seat_keyboard() now takes wlr_keyboard 2022-03-23 18:09:54 +01:00
tree Remove all sprintf calls 2022-02-08 09:20:13 -05:00
commands.c Add focused_tab_title 2021-12-10 16:09:29 +01:00
config.c Add focused_tab_title 2021-12-10 16:09:29 +01:00
criteria.c Updating criteria checking with PCRE2 2022-03-15 11:28:04 +01:00
decoration.c Fix double free when unmapping any view 2018-11-15 15:22:09 +10:00
ipc-json.c [IPC] Add repeat delay/rate info to keyboard 2022-01-04 10:55:05 +01:00
ipc-server.c sway: replace noop_output by fallback_output 2021-11-25 17:48:34 +01:00
main.c sway/main: move constants off the stack 2022-03-29 08:42:17 +02:00
meson.build Replace pcre with pcre2 2022-03-12 14:02:32 +01:00
server.c Avoid format-truncation warning 2022-04-09 18:27:57 +02:00
sway-bar.5.scd man: update Pango font description URL 2021-08-04 02:15:04 +02:00
sway-input.5.scd sway-input.5.scd: Fix spelling errors 2021-10-02 10:21:28 +02:00
sway-ipc.7.scd sway-ipc.7.scd: fix typo 2021-09-19 17:28:37 +02:00
sway-output.5.scd Add 'output render_bit_depth [8|10]' command 2021-11-23 15:51:54 +01:00
sway.1.scd man: update maintainer 2021-01-08 09:33:51 +01:00
sway.5.scd Minor update to focus_on_window_activation 2022-02-06 09:11:06 +01:00
swaynag.c Bump RLIMIT_NOFILE 2021-10-30 08:19:35 -06:00
xdg_activation_v1.c Implement xdg-activation-v1 2021-06-02 19:39:40 +02:00
xdg_decoration.c Fix compile after wlroots commit c3e54021f8bbf3ec1c1e5906459be0ae85f5fb8c 2021-10-07 21:29:37 +03:00