From 33ba06504b23d5144b7cf5350781e3e3e608a263 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Fri, 1 Apr 2016 21:13:10 +0800 Subject: [PATCH] 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 --- .../meta-wayland-pointer-constraints.c | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/wayland/meta-wayland-pointer-constraints.c b/src/wayland/meta-wayland-pointer-constraints.c index 88a3b56e2..493072355 100644 --- a/src/wayland/meta-wayland-pointer-constraints.c +++ b/src/wayland/meta-wayland-pointer-constraints.c @@ -449,8 +449,33 @@ meta_wayland_pointer_constraint_maybe_enable (MetaWaylandPointerConstraint *cons return; } - if (!meta_window_appears_focused (constraint->surface->window)) - 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)) + return; + } meta_wayland_pointer_get_relative_coordinates (constraint->seat->pointer, constraint->surface,