On Mon Dec 4 18:25:38 2023 +0000, Rémi Bernon wrote:
How can it happen exactly that we have an active pointer grab but still end up with the pointer entering a different window (or even a different thread's)? Does it even matter? And if it does, do we actually need to unconfine the cursor then?
Pointer constraints are applied per-surface and can be removed and reapplied at any time by the compositor (we can actually track this through events, but I haven't found much benefit in doing so).
Also, from what I understand, it's the foreground thread that receives the ClipCursor callback, but that can become out of sync with the currently pointer focused_hwnd which I am using here.
But now you got me thinking that acting on the currently Wayland focused hwnd is not the right approach, and I should be using the foreground hwnd instead, regardless of its Wayland focus state. This guarantees that this callback will always be called in the matching (i.e., foreground) thread (except possibly the reset case), so no check is required, correct? Of course the constraint will likely be applied by the compositor only when the surface it gets the Wayland focus. Does this make more sense?