[mutter] window: Make meta_window_has_pointer() per protocol implemented
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] window: Make meta_window_has_pointer() per protocol implemented
- Date: Thu, 25 Aug 2016 04:45:10 +0000 (UTC)
commit 9fb891d216478b923f010be23be8790bba6bc7d6
Author: Jonas Ådahl <jadahl gmail com>
Date: Mon Apr 18 17:38:30 2016 +0800
window: Make meta_window_has_pointer() per protocol implemented
https://bugzilla.gnome.org/show_bug.cgi?id=769936
src/core/window-private.h | 1 +
src/core/window.c | 44 +------------------------------------
src/wayland/meta-window-wayland.c | 16 +++++++++++++
src/x11/window-x11.c | 25 +++++++++++++++++++++
4 files changed, 43 insertions(+), 43 deletions(-)
---
diff --git a/src/core/window-private.h b/src/core/window-private.h
index 4e187ce..f99e104 100644
--- a/src/core/window-private.h
+++ b/src/core/window-private.h
@@ -484,6 +484,7 @@ 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 4167628..1d5882a 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -7535,52 +7535,10 @@ 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)
{
- if (meta_is_wayland_compositor ())
- return window_has_pointer_wayland (window);
- else
- return window_has_pointer_x11 (window);
+ return META_WINDOW_GET_CLASS (window)->has_pointer (window);
}
static gboolean
diff --git a/src/wayland/meta-window-wayland.c b/src/wayland/meta-window-wayland.c
index e9136d1..9b5ec5f 100644
--- a/src/wayland/meta-window-wayland.c
+++ b/src/wayland/meta-window-wayland.c
@@ -419,6 +419,21 @@ 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,
@@ -453,6 +468,7 @@ 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 3d47f0d..42e9f20 100644
--- a/src/x11/window-x11.c
+++ b/src/x11/window-x11.c
@@ -1481,6 +1481,30 @@ 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)
{
@@ -1501,6 +1525,7 @@ 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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]