Commit d7cc5dd7 authored by Carlos Garnacho's avatar Carlos Garnacho

xwayland: Improve checks for confined_to on InputOnly windows

In this pretty Wine/Proton specific kludge, we try to handle confining grabs
on InputOnly windows by trying to find the InputOutput window that the pointer
would get visually confined to.

The grabbing window and the visible window come from different clients, so
we used to simply resort to the pointer focus. This is troublesome though, as
the call may happen very soon at a time that the toplevel wasn't yet mapped by
the Wayland compositor, so the pointer focus may well be out of date soon.

In these situations, it does seem that even though the confining grab happens
too early to have the wayland surface mapped. The xserver view of the WindowPtr
does already reflect the size, so use this to find out the better window to
assign the confining grab to, one whose geometry fully contains the InputOnly
window's.
Signed-off-by: Carlos Garnacho's avatarCarlos Garnacho <carlosg@gnome.org>
parent 9890e912
Pipeline #143600 passed with stages
in 7 minutes and 28 seconds
......@@ -228,6 +228,33 @@ xwl_cursor_warped_to(DeviceIntPtr device,
xwl_seat_emulate_pointer_warp(xwl_seat, xwl_window, sprite, x, y);
}
static struct xwl_window *
find_matching_input_output_window(struct xwl_screen *xwl_screen,
WindowPtr window)
{
struct xwl_window *xwl_window;
xorg_list_for_each_entry(xwl_window, &xwl_screen->window_list, link_window) {
/* When confining happens on InputOnly windows, work out the InputOutput
* window that would be covered by its geometry.
*/
if (window->drawable.x < xwl_window->window->drawable.x ||
window->drawable.x + window->drawable.width >=
xwl_window->window->drawable.x + xwl_window->window->drawable.width ||
window->drawable.y < xwl_window->window->drawable.y ||
window->drawable.y + window->drawable.height >=
xwl_window->window->drawable.y + xwl_window->window->drawable.height)
continue;
if (xwl_window->window->drawable.class == InputOnly)
continue;
return xwl_window;
}
return NULL;
}
static void
xwl_cursor_confined_to(DeviceIntPtr device,
ScreenPtr screen,
......@@ -250,14 +277,9 @@ xwl_cursor_confined_to(DeviceIntPtr device,
}
xwl_window = xwl_window_from_window(window);
if (!xwl_window && xwl_seat->focus_window) {
/* Allow confining on InputOnly windows, but only if the geometry
* is the same than the focus window.
*/
if (window->drawable.class == InputOnly) {
DebugF("Confine on InputOnly window, assuming pointer focus\n");
xwl_window = xwl_seat->focus_window;
}
if (!xwl_window && window->drawable.class == InputOnly) {
DebugF("Confine on InputOnly window, finding matching toplevel\n");
xwl_window = find_matching_input_output_window(xwl_screen, window);
}
if (!xwl_window)
return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment