[mutter/wip/xinput2: 37/49] devices: make meta_device_pointer_query_position() return a boolean



commit 656fa71649940fdb41c231912a375c4a11a3d869
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun Jul 3 21:01:15 2011 +0200

    devices: make meta_device_pointer_query_position() return a boolean
    
    like in XQueryPointer/XIQueryPointer, the return value tells whether
    the pointer device is on the same screen than the passed window.

 src/core/device-pointer.c |   15 +++++++++------
 src/core/device-pointer.h |    4 ++--
 src/core/devices-core.c   |    8 ++++----
 src/core/devices-xi2.c    |   17 ++++++++++-------
 4 files changed, 25 insertions(+), 19 deletions(-)
---
diff --git a/src/core/device-pointer.c b/src/core/device-pointer.c
index cd78229..d9c96d4 100644
--- a/src/core/device-pointer.c
+++ b/src/core/device-pointer.c
@@ -71,7 +71,7 @@ meta_device_pointer_set_window_cursor (MetaDevicePointer *pointer,
     (klass->set_window_cursor) (pointer, xwindow, cursor);
 }
 
-void
+gboolean
 meta_device_pointer_query_position (MetaDevicePointer *pointer,
                                     Window             xwindow,
                                     Window            *root_ret,
@@ -85,18 +85,19 @@ meta_device_pointer_query_position (MetaDevicePointer *pointer,
   MetaDevicePointerClass *klass;
   gint root_x, root_y, x, y;
   Window root, child;
+  gboolean retval;
   guint mask;
 
-  g_return_if_fail (META_IS_DEVICE_POINTER (pointer));
-  g_return_if_fail (xwindow != None);
+  g_return_val_if_fail (META_IS_DEVICE_POINTER (pointer), FALSE);
+  g_return_val_if_fail (xwindow != None, FALSE);
 
   klass = META_DEVICE_POINTER_GET_CLASS (pointer);
 
   if (!klass->query_position)
-    return;
+    return FALSE;
 
-  (klass->query_position) (pointer, xwindow, &root, &child,
-                           &root_x, &root_y, &x, &y, &mask);
+  retval = (klass->query_position) (pointer, xwindow, &root, &child,
+                                    &root_x, &root_y, &x, &y, &mask);
 
   if (root_ret)
     *root_ret = root;
@@ -118,4 +119,6 @@ meta_device_pointer_query_position (MetaDevicePointer *pointer,
 
   if (mask_ret)
     *mask_ret = mask;
+
+  return retval;
 }
diff --git a/src/core/device-pointer.h b/src/core/device-pointer.h
index 1a45aac..6d96eef 100644
--- a/src/core/device-pointer.h
+++ b/src/core/device-pointer.h
@@ -61,7 +61,7 @@ struct _MetaDevicePointerClass
   void (* set_window_cursor)  (MetaDevicePointer *pointer,
                                Window             xwindow,
                                MetaCursor         cursor);
-  void (* query_position)     (MetaDevicePointer *pointer,
+  gboolean (* query_position) (MetaDevicePointer *pointer,
                                Window             xwindow,
                                Window            *root,
                                Window            *child,
@@ -82,7 +82,7 @@ void     meta_device_pointer_set_window_cursor (MetaDevicePointer *pointer,
 						Window             xwindow,
 						MetaCursor         cursor);
 
-void     meta_device_pointer_query_position    (MetaDevicePointer *pointer,
+gboolean meta_device_pointer_query_position    (MetaDevicePointer *pointer,
                                                 Window             xwindow,
                                                 Window            *root,
                                                 Window            *child,
diff --git a/src/core/devices-core.c b/src/core/devices-core.c
index 6848dc8..3f7eaeb 100644
--- a/src/core/devices-core.c
+++ b/src/core/devices-core.c
@@ -114,7 +114,7 @@ meta_device_pointer_core_set_window_cursor (MetaDevicePointer *pointer,
     XFreeCursor (display->xdisplay, xcursor);
 }
 
-static void
+static gboolean
 meta_device_pointer_core_query_position (MetaDevicePointer *pointer,
                                          Window             xwindow,
                                          Window            *root,
@@ -128,9 +128,9 @@ meta_device_pointer_core_query_position (MetaDevicePointer *pointer,
   MetaDisplay *display;
 
   display = meta_device_get_display (META_DEVICE (pointer));
-  XQueryPointer (display->xdisplay, xwindow,
-                 root, child, root_x, root_y,
-                 x, y, mask);
+  return XQueryPointer (display->xdisplay, xwindow,
+                        root, child, root_x, root_y,
+                        x, y, mask);
 }
 
 static void
diff --git a/src/core/devices-xi2.c b/src/core/devices-xi2.c
index ab2f68d..cd6fb1b 100644
--- a/src/core/devices-xi2.c
+++ b/src/core/devices-xi2.c
@@ -193,7 +193,7 @@ meta_device_pointer_xi2_set_window_cursor (MetaDevicePointer *pointer,
     XIUndefineCursor (display->xdisplay, device_id, xwindow);
 }
 
-static void
+static gboolean
 meta_device_pointer_xi2_query_position (MetaDevicePointer *pointer,
                                         Window             xwindow,
                                         Window            *root_ret,
@@ -210,16 +210,17 @@ meta_device_pointer_xi2_query_position (MetaDevicePointer *pointer,
   XIButtonState buttons;
   gdouble root_x, root_y, x, y;
   int device_id;
+  gboolean retval;
 
   display = meta_device_get_display (META_DEVICE (pointer));
   device_id = meta_device_get_id (META_DEVICE (pointer));
 
-  XIQueryPointer (display->xdisplay,
-                  device_id, xwindow,
-                  root_ret, child_ret,
-                  &root_x, &root_y, &x, &y,
-                  &buttons, &mods,
-                  &group_unused);
+  retval = XIQueryPointer (display->xdisplay,
+                           device_id, xwindow,
+                           root_ret, child_ret,
+                           &root_x, &root_y, &x, &y,
+                           &buttons, &mods,
+                           &group_unused);
   if (mask_ret)
     {
       *mask_ret = mods.effective;
@@ -243,6 +244,8 @@ meta_device_pointer_xi2_query_position (MetaDevicePointer *pointer,
 
   if (y_ret)
     *y_ret = (int) y;
+
+  return retval;
 }
 
 static void



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