From f38c1f6ab4a45d409077962b0324cade8582f0ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Wed, 7 May 2014 23:22:41 +0200 Subject: [PATCH] window: Fix delayed mouse mode on X On X, basing the check whether the pointer is on the window on Clutter events does not work, as the relevant events are handled by GDK instead. So add an X-specific window_has_pointer() implementation to also fix mouse mode when running as X compositor. https://bugzilla.gnome.org/show_bug.cgi?id=730541 --- src/core/window.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/src/core/window.c b/src/core/window.c index 9bbfbced6..53880e406 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -7699,7 +7699,7 @@ mouse_mode_focus (MetaWindow *window, } static gboolean -window_has_pointer (MetaWindow *window) +window_has_pointer_wayland (MetaWindow *window) { ClutterDeviceManager *dm; ClutterInputDevice *dev; @@ -7713,6 +7713,39 @@ window_has_pointer (MetaWindow *window) return pointer_actor && clutter_actor_contains (window_actor, pointer_actor); } +static gboolean +window_has_pointer_x11 (MetaWindow *window) +{ + MetaDisplay *display = window->display; + MetaScreen *screen = window->screen; + Window root, child; + double root_x, root_y, x, y; + XIButtonState buttons; + XIModifierState mods; + XIGroupState group; + + meta_error_trap_push (display); + XIQueryPointer (display->xdisplay, + META_VIRTUAL_CORE_POINTER_ID, + screen->xroot, + &root, &child, + &root_x, &root_y, &x, &y, + &buttons, &mods, &group); + meta_error_trap_pop (display); + free (buttons.mask); + + return meta_display_lookup_x_window (display, child) == window; +} + +static gboolean +window_has_pointer (MetaWindow *window) +{ + if (meta_is_wayland_compositor ()) + return window_has_pointer_wayland (window); + else + return window_has_pointer_x11 (window); +} + static gboolean window_focus_on_pointer_rest_callback (gpointer data) {