MetaWaylandPointerConstraints: Relax enable requirements for Xwayland

Xwayland surfaces are special, because there is no reliable way to
associate a window with its corresponding "application window" (the one
which was given focus). Many games that require pointer warping and
confining pointer grabs may for example create override redirect windows
and make that window receive input even though it will never be the
focus window.

Therefore, the requirements for enabling a constraint for a wl_surface
from Xwayland needs to be relaxed in order. This commit changes
Xwayland wl_surfaces to not require being focused to be enabled; it'll
be enabled as long as any X11 window is the one with focus.

https://bugzilla.gnome.org/show_bug.cgi?id=771050
This commit is contained in:
Jonas Ådahl 2016-04-01 21:13:10 +08:00
parent 10c7035a71
commit 33ba06504b

View File

@ -449,8 +449,33 @@ meta_wayland_pointer_constraint_maybe_enable (MetaWaylandPointerConstraint *cons
return; return;
} }
if (meta_xwayland_is_xwayland_surface (constraint->surface))
{
MetaDisplay *display = meta_get_display ();
/*
* We need to handle Xwayland surfaces differently in order to allow
* Xwayland to be able to lock the pointer. For example, we cannot require
* the locked window to "appear focused" because the surface Xwayland
* locks might not be able to appear focused (for example it may be a
* override redirect window).
*
* Since we don't have any way to know what focused window an override
* redirect is associated with, nor have a way to know if the override
* redirect window even shares the same connection as a focused window,
* we simply can only really restrict it to enable the lock if any
* Xwayland window appears focused.
*/
if (display->focus_window &&
display->focus_window->client_type != META_WINDOW_CLIENT_TYPE_X11)
return;
}
else
{
if (!meta_window_appears_focused (constraint->surface->window)) if (!meta_window_appears_focused (constraint->surface->window))
return; return;
}
meta_wayland_pointer_get_relative_coordinates (constraint->seat->pointer, meta_wayland_pointer_get_relative_coordinates (constraint->seat->pointer,
constraint->surface, constraint->surface,