From 0236506cff730d9e198fbfdbc167d49a9e8124c7 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Thu, 24 Aug 2023 15:45:06 +0200 Subject: [PATCH] window: Move has_pointer_x11 to WindowX11 Part-of: --- src/core/window.c | 33 +++++++++------------------------ src/x11/window-x11-private.h | 2 ++ src/x11/window-x11.c | 23 +++++++++++++++++++++++ 3 files changed, 34 insertions(+), 24 deletions(-) diff --git a/src/core/window.c b/src/core/window.c index 489f73a73..1c9aa013e 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -90,6 +90,10 @@ #include "x11/window-x11.h" #include "x11/xprops.h" +#ifdef HAVE_X11_CLIENT +#include "x11/window-x11-private.h" +#endif + #ifdef HAVE_WAYLAND #include "wayland/meta-wayland-private.h" #include "wayland/meta-wayland-surface-private.h" @@ -7314,36 +7318,17 @@ window_has_pointer_wayland (MetaWindow *window) return pointer_actor && clutter_actor_contains (window_actor, pointer_actor); } -static gboolean -window_has_pointer_x11 (MetaWindow *window) -{ - MetaX11Display *x11_display = window->display->x11_display; - Window root, child; - double root_x, root_y, x, y; - XIButtonState buttons; - XIModifierState mods; - XIGroupState group; - - meta_x11_error_trap_push (x11_display); - XIQueryPointer (x11_display->xdisplay, - META_VIRTUAL_CORE_POINTER_ID, - x11_display->xroot, - &root, &child, - &root_x, &root_y, &x, &y, - &buttons, &mods, &group); - meta_x11_error_trap_pop (x11_display); - free (buttons.mask); - - return meta_x11_display_lookup_x_window (x11_display, child) == window; -} - gboolean meta_window_has_pointer (MetaWindow *window) { if (meta_is_wayland_compositor ()) return window_has_pointer_wayland (window); +#ifdef HAVE_X11_CLIENT else - return window_has_pointer_x11 (window); + return meta_window_x11_has_pointer (window); +#else + g_assert_not_reached (); +#endif } void diff --git a/src/x11/window-x11-private.h b/src/x11/window-x11-private.h index 82b4d4d99..2d1bea401 100644 --- a/src/x11/window-x11-private.h +++ b/src/x11/window-x11-private.h @@ -100,4 +100,6 @@ Window meta_window_x11_get_user_time_window (MetaWindow *window); Window meta_window_x11_get_xtransient_for (MetaWindow *window); +gboolean meta_window_x11_has_pointer (MetaWindow *window); + G_END_DECLS diff --git a/src/x11/window-x11.c b/src/x11/window-x11.c index 0df482495..cb187107f 100644 --- a/src/x11/window-x11.c +++ b/src/x11/window-x11.c @@ -4463,3 +4463,26 @@ meta_window_x11_get_xtransient_for (MetaWindow *window) return None; } + +gboolean +meta_window_x11_has_pointer (MetaWindow *window) +{ + MetaX11Display *x11_display = window->display->x11_display; + Window root, child; + double root_x, root_y, x, y; + XIButtonState buttons; + XIModifierState mods; + XIGroupState group; + + meta_x11_error_trap_push (x11_display); + XIQueryPointer (x11_display->xdisplay, + META_VIRTUAL_CORE_POINTER_ID, + x11_display->xroot, + &root, &child, + &root_x, &root_y, &x, &y, + &buttons, &mods, &group); + meta_x11_error_trap_pop (x11_display); + free (buttons.mask); + + return meta_x11_display_lookup_x_window (x11_display, child) == window; +}