[gtk+/xi2: 928/1239] GdkDisplay: Add gdk_display_device_is_grabbed().



commit 968378bcd73cbc1952c11fd10c39dfd843eae65b
Author: Carlos Garnacho <carlos lanedo com>
Date:   Sat Aug 29 17:34:54 2009 +0200

    GdkDisplay: Add gdk_display_device_is_grabbed().
    
    Also, implement gdk_display_pointer_is_grabbed() on top of it.

 gdk/gdkdisplay.c |   30 ++++++++++++++++++++++++++++--
 gdk/gdkdisplay.h |    2 ++
 2 files changed, 30 insertions(+), 2 deletions(-)
---
diff --git a/gdk/gdkdisplay.c b/gdk/gdkdisplay.c
index b0316ea..6104511 100644
--- a/gdk/gdkdisplay.c
+++ b/gdk/gdkdisplay.c
@@ -1546,15 +1546,41 @@ gdk_pointer_grab_info_libgtk_only (GdkDisplay *display,
 gboolean
 gdk_display_pointer_is_grabbed (GdkDisplay *display)
 {
+  GdkDeviceManager *device_manager;
   GdkPointerGrabInfo *info;
+  GList *devices, *dev;
+  GdkDevice *device;
 
   g_return_val_if_fail (GDK_IS_DISPLAY (display), TRUE);
 
+  device_manager = gdk_device_manager_get_for_display (display);
+  devices = gdk_device_manager_get_devices (device_manager, GDK_DEVICE_TYPE_MASTER);
+
+  for (dev = devices; dev; dev = dev->next)
+    {
+      device = dev->data;
+
+      if (device->source = GDK_SOURCE_MOUSE &&
+          gdk_display_device_is_grabbed (display, device))
+        return TRUE;
+    }
+
+  return FALSE;
+}
+
+gboolean
+gdk_display_device_is_grabbed (GdkDisplay *display,
+                               GdkDevice  *device)
+{
+  GdkPointerGrabInfo *info;
+
+  g_return_val_if_fail (GDK_IS_DISPLAY (display), TRUE);
+  g_return_val_if_fail (GDK_IS_DEVICE (device), TRUE);
+
   /* What we're interested in is the steady state (ie last grab),
      because we're interested e.g. if we grabbed so that we
      can ungrab, even if our grab is not active just yet. */
-  /* FIXME: which device? */
-  info = _gdk_display_get_last_pointer_grab (display, display->core_pointer);
+  info = _gdk_display_get_last_pointer_grab (display, device);
 
   return (info && !info->implicit);
 }
diff --git a/gdk/gdkdisplay.h b/gdk/gdkdisplay.h
index 2b562e3..0ecc7bc 100644
--- a/gdk/gdkdisplay.h
+++ b/gdk/gdkdisplay.h
@@ -181,6 +181,8 @@ void        gdk_display_pointer_ungrab     (GdkDisplay  *display,
 void        gdk_display_keyboard_ungrab    (GdkDisplay  *display,
 					    guint32      time_);
 gboolean    gdk_display_pointer_is_grabbed (GdkDisplay  *display);
+gboolean    gdk_display_device_is_grabbed  (GdkDisplay  *display,
+                                            GdkDevice   *device);
 void        gdk_display_beep               (GdkDisplay  *display);
 void        gdk_display_sync               (GdkDisplay  *display);
 void        gdk_display_flush              (GdkDisplay  *display);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]