[mutter/gbsneto/cleanup-x11-from-meta-window: 162/164] window: Delegate meta_window_has_pointer to subclasses
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/gbsneto/cleanup-x11-from-meta-window: 162/164] window: Delegate meta_window_has_pointer to subclasses
- Date: Wed, 13 Feb 2019 08:06:20 +0000 (UTC)
commit ed7fc825e1de8b7aacc4c5c506350d535644a690
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Sat Dec 22 19:10:59 2018 -0200
window: Delegate meta_window_has_pointer to subclasses
meta_window_has_pointer() is already aware of X11 or Wayland
specific implementations, but it makes more sense to have it
implemented by the subclasses themselves.
Move the Wayland and X11 code paths to their respective subclasses
through a new vfunc MetaWindowClass.has_pointer().
https://gitlab.gnome.org/GNOME/mutter/merge_requests/372
src/core/window-private.h | 1 +
src/core/window.c | 43 +-------------------------------------
src/wayland/meta-window-wayland.c | 16 ++++++++++++++
src/wayland/meta-window-xwayland.c | 16 ++++++++++++++
src/x11/window-x11.c | 24 +++++++++++++++++++++
5 files changed, 58 insertions(+), 42 deletions(-)
---
diff --git a/src/core/window-private.h b/src/core/window-private.h
index d7c8700ce..4fffdb563 100644
--- a/src/core/window-private.h
+++ b/src/core/window-private.h
@@ -557,6 +557,7 @@ struct _MetaWindowClass
gboolean (*is_stackable) (MetaWindow *window);
gboolean (*can_ping) (MetaWindow *window);
gboolean (*are_updates_frozen) (MetaWindow *window);
+ 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 47a836497..15f8aab60 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -8106,51 +8106,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)
-{
- 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);
- 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 9515a2103..90181f42a 100644
--- a/src/wayland/meta-window-wayland.c
+++ b/src/wayland/meta-window-wayland.c
@@ -621,6 +621,21 @@ meta_window_wayland_are_updates_frozen (MetaWindow *window)
return !wl_window->has_been_shown;
}
+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
meta_window_wayland_class_init (MetaWindowWaylandClass *klass)
{
@@ -646,6 +661,7 @@ meta_window_wayland_class_init (MetaWindowWaylandClass *klass)
window_class->is_stackable = meta_window_wayland_is_stackable;
window_class->can_ping = meta_window_wayland_can_ping;
window_class->are_updates_frozen = meta_window_wayland_are_updates_frozen;
+ window_class->has_pointer = meta_window_wayland_has_pointer;
}
MetaWindow *
diff --git a/src/wayland/meta-window-xwayland.c b/src/wayland/meta-window-xwayland.c
index 6f073893a..03f6952bb 100644
--- a/src/wayland/meta-window-xwayland.c
+++ b/src/wayland/meta-window-xwayland.c
@@ -71,6 +71,21 @@ meta_window_xwayland_shortcuts_inhibited (MetaWindow *window,
return meta_wayland_compositor_is_shortcuts_inhibited (compositor, source);
}
+static gboolean
+meta_window_xwayland_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
meta_window_xwayland_get_property (GObject *object,
guint prop_id,
@@ -117,6 +132,7 @@ meta_window_xwayland_class_init (MetaWindowXwaylandClass *klass)
window_class->force_restore_shortcuts = meta_window_xwayland_force_restore_shortcuts;
window_class->shortcuts_inhibited = meta_window_xwayland_shortcuts_inhibited;
+ window_class->has_pointer = meta_window_xwayland_has_pointer;
gobject_class->get_property = meta_window_xwayland_get_property;
gobject_class->set_property = meta_window_xwayland_set_property;
diff --git a/src/x11/window-x11.c b/src/x11/window-x11.c
index 80193dbbf..167c22dfe 100644
--- a/src/x11/window-x11.c
+++ b/src/x11/window-x11.c
@@ -1743,6 +1743,29 @@ meta_window_x11_are_updates_frozen (MetaWindow *window)
return FALSE;
}
+static 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;
+}
+
static void
meta_window_x11_class_init (MetaWindowX11Class *klass)
{
@@ -1772,6 +1795,7 @@ meta_window_x11_class_init (MetaWindowX11Class *klass)
window_class->is_stackable = meta_window_x11_is_stackable;
window_class->can_ping = meta_window_x11_can_ping;
window_class->are_updates_frozen = meta_window_x11_are_updates_frozen;
+ window_class->has_pointer = meta_window_x11_has_pointer;
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]