diff --git a/src/core/window-private.h b/src/core/window-private.h index 7d30652ed..7793dccb9 100644 --- a/src/core/window-private.h +++ b/src/core/window-private.h @@ -527,7 +527,6 @@ struct _MetaWindowClass void (*update_main_monitor) (MetaWindow *window); void (*main_monitor_changed) (MetaWindow *window, const MetaMonitorInfo *old); - gboolean (*has_pointer) (MetaWindow *window); }; /* These differ from window->has_foo_func in that they consider diff --git a/src/core/window.c b/src/core/window.c index 9cfb09535..fc9477fed 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -7534,10 +7534,52 @@ mouse_mode_focus (MetaWindow *window, } } +static gboolean +window_has_pointer_wayland (MetaWindow *window) +{ + ClutterDeviceManager *dm; + ClutterInputDevice *dev; + ClutterActor *pointer_actor, *window_actor; + + dm = clutter_device_manager_get_default (); + dev = clutter_device_manager_get_core_device (dm, CLUTTER_POINTER_DEVICE); + pointer_actor = clutter_input_device_get_pointer_actor (dev); + window_actor = CLUTTER_ACTOR (meta_window_get_compositor_private (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; +} + gboolean meta_window_has_pointer (MetaWindow *window) { - return META_WINDOW_GET_CLASS (window)->has_pointer (window); + if (meta_is_wayland_compositor ()) + return window_has_pointer_wayland (window); + else + return window_has_pointer_x11 (window); } static gboolean diff --git a/src/wayland/meta-window-wayland.c b/src/wayland/meta-window-wayland.c index f24fa2560..85c4296ec 100644 --- a/src/wayland/meta-window-wayland.c +++ b/src/wayland/meta-window-wayland.c @@ -432,21 +432,6 @@ meta_window_wayland_main_monitor_changed (MetaWindow *window, meta_window_emit_size_changed (window); } -static gboolean -meta_window_wayland_has_pointer (MetaWindow *window) -{ - ClutterDeviceManager *dm; - ClutterInputDevice *dev; - ClutterActor *pointer_actor, *window_actor; - - dm = clutter_device_manager_get_default (); - dev = clutter_device_manager_get_core_device (dm, CLUTTER_POINTER_DEVICE); - pointer_actor = clutter_input_device_get_pointer_actor (dev); - window_actor = CLUTTER_ACTOR (meta_window_get_compositor_private (window)); - - return pointer_actor && clutter_actor_contains (window_actor, pointer_actor); -} - static void appears_focused_changed (GObject *object, GParamSpec *pspec, @@ -481,7 +466,6 @@ meta_window_wayland_class_init (MetaWindowWaylandClass *klass) window_class->move_resize_internal = meta_window_wayland_move_resize_internal; window_class->update_main_monitor = meta_window_wayland_update_main_monitor; window_class->main_monitor_changed = meta_window_wayland_main_monitor_changed; - window_class->has_pointer = meta_window_wayland_has_pointer; } MetaWindow * diff --git a/src/x11/window-x11.c b/src/x11/window-x11.c index 42e9f2067..3d47f0d4e 100644 --- a/src/x11/window-x11.c +++ b/src/x11/window-x11.c @@ -1481,30 +1481,6 @@ meta_window_x11_main_monitor_changed (MetaWindow *window, { } -static gboolean -meta_window_x11_has_pointer (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 void meta_window_x11_class_init (MetaWindowX11Class *klass) { @@ -1525,7 +1501,6 @@ meta_window_x11_class_init (MetaWindowX11Class *klass) window_class->update_icon = meta_window_x11_update_icon; window_class->update_main_monitor = meta_window_x11_update_main_monitor; window_class->main_monitor_changed = meta_window_x11_main_monitor_changed; - window_class->has_pointer = meta_window_x11_has_pointer; } void