summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-01-26 13:57:50 +0000
committerMatthias Clasen <mclasen@redhat.com>2021-01-26 13:57:50 +0000
commit7f08adc23e3604ded52b2f58986517289292c63f (patch)
tree7d83cc4ae333c630449c9a5def51ae7b6805bec3
parent1fe6fb673968d41bea19cebdfef384dc1df9e20d (diff)
parentf41012080fa79c408d0277f7b68d4b2fe14dd69c (diff)
downloadgtk+-7f08adc23e3604ded52b2f58986517289292c63f.tar.gz
Merge branch 'ebassi/for-master' into 'master'
Fixes for gdk_surface_translate_coordinates() See merge request GNOME/gtk!3118
-rw-r--r--gdk/gdksurface.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c
index d0dbf52b85..31c5b44b73 100644
--- a/gdk/gdksurface.c
+++ b/gdk/gdksurface.c
@@ -2960,8 +2960,8 @@ gdk_surface_request_motion (GdkSurface *surface)
* gdk_surface_translate_coordinates:
* @from: the origin surface
* @to: the target surface
- * @x: (out): coordinates to translate
- * @y: (out): coordinates to translate
+ * @x: (inout): coordinates to translate
+ * @y: (inout): coordinates to translate
*
* Translates the given coordinates from being
* relative to the @from surface to being relative
@@ -2980,9 +2980,18 @@ gdk_surface_translate_coordinates (GdkSurface *from,
double *x,
double *y)
{
+ double in_x, in_y, out_x, out_y;
int x1, y1, x2, y2;
GdkSurface *f, *t;
+ g_return_val_if_fail (GDK_IS_SURFACE (from), FALSE);
+ g_return_val_if_fail (GDK_IS_SURFACE (to), FALSE);
+ g_return_val_if_fail (x != NULL, FALSE);
+ g_return_val_if_fail (y != NULL, FALSE);
+
+ in_x = *x;
+ in_y = *y;
+
x1 = 0;
y1 = 0;
f = from;
@@ -3006,8 +3015,11 @@ gdk_surface_translate_coordinates (GdkSurface *from,
if (f != t)
return FALSE;
- *x += x1 - x2;
- *y += y1 - y2;
+ out_x = in_x + (x1 - x2);
+ out_y = in_y + (y1 - y2);
+
+ *x = out_x;
+ *y = out_y;
return TRUE;
}