[mutter/wip/wayland-work: 17/22] MetaCursorTracker: extend with query pointer abilities
- From: Giovanni Campagna <gcampagna src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/wayland-work: 17/22] MetaCursorTracker: extend with query pointer abilities
- Date: Mon, 9 Sep 2013 13:42:02 +0000 (UTC)
commit 89e599c89c5fb615803b513a2ac5bfba63fe1fb6
Author: Giovanni Campagna <gcampagn redhat com>
Date: Wed Sep 4 16:50:19 2013 +0200
MetaCursorTracker: extend with query pointer abilities
We need an abstraction in gnome-shell for XQueryPointer, and
MetaCursorTracker seems a good place for it.
https://bugzilla.gnome.org/show_bug.cgi?id=707474
src/core/meta-cursor-tracker.c | 59 +++++++++++++++++++++++++++++++++++++++-
src/meta/meta-cursor-tracker.h | 6 ++++
2 files changed, 64 insertions(+), 1 deletions(-)
---
diff --git a/src/core/meta-cursor-tracker.c b/src/core/meta-cursor-tracker.c
index 41ecb69..0ae1786 100644
--- a/src/core/meta-cursor-tracker.c
+++ b/src/core/meta-cursor-tracker.c
@@ -24,7 +24,9 @@
/**
* SECTION:cursor-tracker
* @title: MetaCursorTracker
- * @short_description: Mutter cursor tracking helper
+ * @short_description: Mutter cursor tracking helper. Originally only
+ * tracking the cursor image, now more of a "core
+ * pointer abstraction"
*/
#include <config.h>
@@ -35,6 +37,8 @@
#include <cogl/cogl.h>
#include <clutter/clutter.h>
+#include <gdk/gdk.h>
+
#include <X11/extensions/Xfixes.h>
#include "meta-cursor-tracker-private.h"
@@ -456,3 +460,56 @@ meta_cursor_tracker_queue_redraw (MetaCursorTracker *tracker,
clutter_actor_queue_redraw_with_clip (stage, &tracker->current_rect);
}
+
+static void
+get_pointer_position_gdk (int *x,
+ int *y,
+ int *mods)
+{
+ GdkDeviceManager *gmanager;
+ GdkDevice *gdevice;
+ GdkScreen *gscreen;
+
+ gmanager = gdk_display_get_device_manager (gdk_display_get_default ());
+ gdevice = gdk_device_manager_get_client_pointer (gmanager);
+
+ gdk_device_get_position (gdevice, &gscreen, x, y);
+ gdk_device_get_state (gdevice,
+ gdk_screen_get_root_window (gscreen),
+ NULL, (GdkModifierType*)mods);
+}
+
+static void
+get_pointer_position_clutter (int *x,
+ int *y,
+ int *mods)
+{
+ ClutterDeviceManager *cmanager;
+ ClutterInputDevice *cdevice;
+ ClutterPoint point;
+
+ cmanager = clutter_device_manager_get_default ();
+ cdevice = clutter_device_manager_get_core_device (cmanager, CLUTTER_POINTER_DEVICE);
+
+ clutter_input_device_get_coords (cdevice, NULL, &point);
+ *x = point.x;
+ *y = point.y;
+ *mods = clutter_input_device_get_modifier_state (cdevice);
+}
+
+void
+meta_cursor_tracker_get_pointer (MetaCursorTracker *tracker,
+ int *x,
+ int *y,
+ ClutterModifierType *mods)
+{
+ /* We can't use the clutter interface when not running as a wayland compositor,
+ because we need to query the server, rather than using the last cached value.
+ OTOH, on wayland we can't use GDK, because that only sees the events
+ we forward to xwayland.
+ */
+ if (meta_is_wayland_compositor ())
+ get_pointer_position_clutter (x, y, (int*)mods);
+ else
+ get_pointer_position_gdk (x, y, (int*)mods);
+}
diff --git a/src/meta/meta-cursor-tracker.h b/src/meta/meta-cursor-tracker.h
index c59c6ce..8862e43 100644
--- a/src/meta/meta-cursor-tracker.h
+++ b/src/meta/meta-cursor-tracker.h
@@ -28,6 +28,7 @@
#include <meta/types.h>
#include <meta/workspace.h>
#include <cogl/cogl.h>
+#include <clutter/clutter.h>
#define META_TYPE_CURSOR_TRACKER (meta_cursor_tracker_get_type ())
#define META_CURSOR_TRACKER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), META_TYPE_CURSOR_TRACKER,
MetaCursorTracker))
@@ -47,4 +48,9 @@ void meta_cursor_tracker_get_hot (MetaCursorTracker *tracker,
int *y);
CoglTexture *meta_cursor_tracker_get_sprite (MetaCursorTracker *tracker);
+void meta_cursor_tracker_get_pointer (MetaCursorTracker *tracker,
+ int *x,
+ int *y,
+ ClutterModifierType *mods);
+
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]