summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2020-08-26 09:01:48 -0400
committerMatthias Clasen <mclasen@redhat.com>2020-08-26 09:11:28 -0400
commit74a452df6c04c6c9bff82d96c63c90c4f0ad47fd (patch)
tree65a35540c7fc0f3ebe64bba4af152ed6e89d2907
parentb6eb85ee72c228fd5f9657dce7ac7d352be57ad3 (diff)
downloadgtk+-74a452df6c04c6c9bff82d96c63c90c4f0ad47fd.tar.gz
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.
-rw-r--r--gdk/gdksurface.c25
-rw-r--r--gdk/gdksurface.h2
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,