Alternative to 7bf08af which was reverted in the previous commit.
7bf08af fixed the problem that layer-shell clients are terminated when
it's unmapped, by sending configure events in node-destroy handler
rather than in unmap handler. But it caused a UAF bug when an output
with layer-shell clients is destroyed.
So this patch fixes the original issue by simply skipping the surface in
arrange_one_layer() if it's being unmapped.
This ensures all event listeners are removed before the emitting
wlroots object is being destroyed. This will be enforced with asserts
in wlroots 0.19 but there is no reason to not do it right now either.
This change in wlroots 0.19 is implemented via commit
8f56f7ca43257cc05c7c4eb57a0f541e05cf9a79
"Assert (almost all) signals have no attached listeners on destroy"
See https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3514
which added support on the wlroots side.
We now re-run popup positioning (for both xdg-shell and layer-shell
popups) when the "reposition" event is received. This allows popups that
change size (such as qmpanel's applications menu) to be positioned
correctly.
xdg-shell v3 also gives the compositor some additional "hints" for popup
positioning (reactive, parent_size, and parent_configure_serial) which
are available but we don't make use of currently.
Use the following logic:
- Exclusive: Grant regardless of layer (previously it was only given if
in top or overlay layers) AND grant if in the same or higher layer
(nearer overlay) compared with other clients with exclusive
interactivity.
- On-demand: Grant only if no other layer-shell client has exclusive
keyboard interactivity. Previously it was treated the same as
exclusive.
- None: Unset focus if the commit associated with the 'none' came from
the currently focused layer. Previously it was just unset regardless.
Made all header files to have LABWC_ prefix in include guard identifers.
Converted from __LABWC_ in 35 include/ files.
Converted from __LAB_ in 5 include/ files.
Added LABWC prefix to 3 include/ files.
Added include guards to 3 include/ files.
The double underscores were removed since according to C standard
those "are always reserved for any use".
...and thus simplify the usage of wlr_scene_node_at(). Specifically:
- desktop.c: in get_cursor_context() use node-description for
layer-surfaces and layer-popups. This lays the foundations for a
pointer-enter-event being sent when a new layer-surfaces appears under
the pointer (even if the pointer doesn not move).
- layers.c:
* Iterate over `struct wlr_scene_tree *layer_tree[]` rather than
`struct wl_list layers[]` when arranging layers to avoid surfaces
being out of sync with nodes
* Set signal handlers after scene node creation to avoid configure
race conditions
* Handle scene-node destroy event rather than event of
`struct wlr_layer_surface_v1`
* Arrange layers on map and unmap
* Handle client request for layer-change
Fixes issue #667