From 3053cc0de4e6f25402293bd36da30638f143d204 Mon Sep 17 00:00:00 2001 From: Giovanni Campagna Date: Wed, 4 Sep 2013 16:50:19 +0200 Subject: [PATCH] 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 | 21 +++++++++++++++++++++ src/meta/meta-cursor-tracker.h | 6 ++++++ 2 files changed, 27 insertions(+) diff --git a/src/core/meta-cursor-tracker.c b/src/core/meta-cursor-tracker.c index c51a827de..bfe35d5a5 100644 --- a/src/core/meta-cursor-tracker.c +++ b/src/core/meta-cursor-tracker.c @@ -35,6 +35,8 @@ #include #include +#include + #include #include "meta-cursor-tracker-private.h" @@ -273,3 +275,22 @@ meta_cursor_tracker_set_root_cursor (MetaCursorTracker *tracker, XFlush (display->xdisplay); XFreeCursor (display->xdisplay, xcursor); } + +void +meta_cursor_tracker_get_pointer (MetaCursorTracker *tracker, + int *x, + int *y, + ClutterModifierType *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); +} diff --git a/src/meta/meta-cursor-tracker.h b/src/meta/meta-cursor-tracker.h index c59c6cefb..8862e4345 100644 --- a/src/meta/meta-cursor-tracker.h +++ b/src/meta/meta-cursor-tracker.h @@ -28,6 +28,7 @@ #include #include #include +#include #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