[gtk: 24/60] Make gdk_surface_get_device_position return a boolean




commit 028644d0adfe8c60e96ebf52e96ab48f15c84fa8
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Aug 26 09:01:48 2020 -0400

    Make gdk_surface_get_device_position return a boolean
    
    A year ago, we make this function not return the child
    surface anymore. But the information whether the device
    is actually over the surface is still useful, and we
    should not loose it.

 gdk/gdksurface.c | 25 ++++++++++++++++---------
 gdk/gdksurface.h |  2 +-
 2 files changed, 17 insertions(+), 10 deletions(-)
---
diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c
index cf471d49c6..f89061a002 100644
--- a/gdk/gdksurface.c
+++ b/gdk/gdksurface.c
@@ -1627,8 +1627,10 @@ gdk_surface_constrain_size (GdkGeometry    *geometry,
  * Obtains the current device position in doubles and modifier state.
  * The position is given in coordinates relative to the upper left
  * corner of @surface.
+ *
+ * Return: %TRUE if the device is over the surface
  **/
-void
+gboolean
 gdk_surface_get_device_position (GdkSurface       *surface,
                                  GdkDevice       *device,
                                  double          *x,
@@ -1637,17 +1639,20 @@ gdk_surface_get_device_position (GdkSurface       *surface,
 {
   double tmp_x, tmp_y;
   GdkModifierType tmp_mask;
+  gboolean ret;
 
-  g_return_if_fail (GDK_IS_SURFACE (surface));
-  g_return_if_fail (GDK_IS_DEVICE (device));
-  g_return_if_fail (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD);
+  g_return_val_if_fail (GDK_IS_SURFACE (surface), FALSE);
+  g_return_val_if_fail (GDK_IS_DEVICE (device), FALSE);
+  g_return_val_if_fail (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD, FALSE);
 
-  tmp_x = tmp_y = 0;
+  tmp_x = 0;
+  tmp_y = 0;
   tmp_mask = 0;
-  GDK_SURFACE_GET_CLASS (surface)->get_device_state (surface,
-                                                     device,
-                                                     &tmp_x, &tmp_y,
-                                                     &tmp_mask);
+
+  ret = GDK_SURFACE_GET_CLASS (surface)->get_device_state (surface,
+                                                           device,
+                                                           &tmp_x, &tmp_y,
+                                                           &tmp_mask);
 
   if (x)
     *x = tmp_x;
@@ -1655,6 +1660,8 @@ gdk_surface_get_device_position (GdkSurface       *surface,
     *y = tmp_y;
   if (mask)
     *mask = tmp_mask;
+
+  return ret;
 }
 
 /**
diff --git a/gdk/gdksurface.h b/gdk/gdksurface.h
index 9b1613147f..a03b02a4e3 100644
--- a/gdk/gdksurface.h
+++ b/gdk/gdksurface.h
@@ -187,7 +187,7 @@ GDK_AVAILABLE_IN_ALL
 int           gdk_surface_get_scale_factor  (GdkSurface     *surface);
 
 GDK_AVAILABLE_IN_ALL
-void          gdk_surface_get_device_position (GdkSurface      *surface,
+gboolean      gdk_surface_get_device_position (GdkSurface      *surface,
                                                GdkDevice       *device,
                                                double          *x,
                                                double          *y,


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