aboutsummaryrefslogtreecommitdiff
path: root/sway/commands/bar.c
diff options
context:
space:
mode:
authorThomas Hebb <tommyhebb@gmail.com>2022-02-06 12:21:27 -0800
committerSimon Ser <contact@emersion.fr>2022-04-13 10:05:24 +0200
commitd726e50643d6e54bdb5882008e13bf5d20a1c3ba (patch)
tree459f4f106efd258093af96dbe53cfd00276fbf44 /sway/commands/bar.c
parentcf413b9c0b688689a3d4e29d873a749889ecc971 (diff)
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 c9060bcc12d0 ("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 a0bbe67076b8 ("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.
Diffstat (limited to 'sway/commands/bar.c')
0 files changed, 0 insertions, 0 deletions