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
This commit is contained in:
Giovanni Campagna 2013-09-04 16:50:19 +02:00
parent 0b89e34439
commit 3053cc0de4
2 changed files with 27 additions and 0 deletions

View File

@ -35,6 +35,8 @@
#include <cogl/cogl.h> #include <cogl/cogl.h>
#include <clutter/clutter.h> #include <clutter/clutter.h>
#include <gdk/gdk.h>
#include <X11/extensions/Xfixes.h> #include <X11/extensions/Xfixes.h>
#include "meta-cursor-tracker-private.h" #include "meta-cursor-tracker-private.h"
@ -273,3 +275,22 @@ meta_cursor_tracker_set_root_cursor (MetaCursorTracker *tracker,
XFlush (display->xdisplay); XFlush (display->xdisplay);
XFreeCursor (display->xdisplay, xcursor); 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);
}

View File

@ -28,6 +28,7 @@
#include <meta/types.h> #include <meta/types.h>
#include <meta/workspace.h> #include <meta/workspace.h>
#include <cogl/cogl.h> #include <cogl/cogl.h>
#include <clutter/clutter.h>
#define META_TYPE_CURSOR_TRACKER (meta_cursor_tracker_get_type ()) #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)) #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); int *y);
CoglTexture *meta_cursor_tracker_get_sprite (MetaCursorTracker *tracker); CoglTexture *meta_cursor_tracker_get_sprite (MetaCursorTracker *tracker);
void meta_cursor_tracker_get_pointer (MetaCursorTracker *tracker,
int *x,
int *y,
ClutterModifierType *mods);
#endif #endif