From the spec:
> The wl_pointer.enter and wl_pointer.leave events are logical events
> generated by the compositor and not the hardware. These events are
> also grouped by a wl_pointer.frame. When a pointer moves from one
> surface to another, a compositor should group the wl_pointer.leave
> event within the same wl_pointer.frame. However, a client must not
> rely on wl_pointer.leave and wl_pointer.enter being in the same
> wl_pointer.frame. Compositor-specific policies may require the
> wl_pointer.leave and wl_pointer.enter event being split across
> multiple wl_pointer.frame groups.
From my understanding™ this means that a compositor SHOULD group
leave/enter events together. Is this common? From my testing... Not
really. Notably, (only?) KDE does this.
Our pointer frame event assumed that we would be working with the
currently pointed window but since all events must be logically grouped
together I think it can really only group "normal" events related to the
*leave* event.
Now, whenever there's a pointer focus change, we send everything to the
old window, if it exists, otherwise the currently pointed one.
This approach seems to handle complex event frames with both leave and
enter events properly now, with good results on all compositors.
This patch also and makes it harder to get to a null check when the
window simply does not exists (the error was meant only for existing but
invalid windows), along with an helper method to aid in this.
Fixes#117676
PR #111964 made a Ref<ColorManagementProfile> which we intentionally
leaked across a client-server barrier owned, which caused a use-after-free.
Manually adding reference/unreference calls keeps the ptr valid without memory leaks.
We now pass the buffer scale along the window size to the display server
and set everything from there.
This should avoid races where the buffer scale changes while we handle
window rect changes.
We now reuse the `global_remove` event handler. This removes a
considerable amount of duplication, minimizes human error (such as
cleaning up a global in one place but not the other), and helps test the
dynamic global removal logic.
We assumed that a window will be ready after a single roundtrip but
that's actually not guaranteed by the XDG shell protocol.
This patch waits for an arbitrary timeout (10s) before erroring out and
forcefully closing the window. Since this exercised quite some code
paths, it also reworks some window handling logic and fixes a bunch of
synchronization issues.
This will allow decoupling `display_server.h` from a number of headers in the
codebase which only require those enums and not all the DisplayServer API.
They were bound in reverse. No idea how I originally chose which was
which.
This patch also orders the switch cases by their underlying codes: left,
right, middle, side, extra.
Some compositors (e.g. COSMIC) can report *all* supported output modes,
not just the current mode. This is valid, albeit deprecated, so let's
add a check and ignore any non-current output events.
The spec tells us to ignore certain events if we didn't get an `enter`
event first. Certainly we need to at least acknowledge the `enter` event
itself 😅
Despite what I thought in the past, it is allowed, as long as we follow
certain limitations depending on the toplevel's state.
As usual I peppered the code with comments expaining what those
limitations are.
Regarding popups, AFAICT there are no major limitations, although we
should eventually use the new `reposition` method, which autoadjusts the
popup to follow the screen's borders and whatnot. I didn't do that in
this patch as it requires some elbow grease, especially if we want to do
it synchronously.
Libdecor has some quirks and depending on the setup it might be useful
to switch to the xdg-shell branch. Recompiling the whole engine without
libdecor is not an acceptable way to do that.
Makes it more consistent with the rest of the `WaylandThread` methods
(so that we can silently check for the window's existence).
Fixes errors when trying to capture the pointer when no surface has been
pointed yet (its logic assumed that this method was silent).
We double-check everywhere anyway but I added it in some places where we
can't either guarantee that it'll check (to avoid segfaults) or that
would be useful to report directly.
The spec says "After leave event, compositor must ignore requests from
any text input instances until next enter event."
Fixes an error on jay, which at least on 1.11.0 sends
`zwp_text_input_v3::done` after `zwp_text_input_v3::leave`, which we
didn't ignore, leading to a commit without a valid window id.
scale_changed and size_changed were incorrectly initialized to true,
causing redundant WindowRectMessage and DPI change events to be pushed
on every configure event regardless of actual changes.