[gtk: 9/16] x11: Make gdk_surface_get_position() return relative position
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk: 9/16] x11: Make gdk_surface_get_position() return relative position
- Date: Wed, 19 Feb 2020 18:58:48 +0000 (UTC)
commit 40693412d3ccdc875b3e8ea635ffcb5b6c75cbd4
Author: Jonas Ã…dahl <jadahl gmail com>
Date: Sun Feb 16 00:28:01 2020 +0100
x11: Make gdk_surface_get_position() return relative position
The returned position should be relative to the parent surface, but
GdkSurface::x,y were only managed properly for O-R windows. This makes
it correct for regular windows too.
gdk/x11/gdkdisplay-x11.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
---
diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c
index 7c143b52ff..1440eab426 100644
--- a/gdk/x11/gdkdisplay-x11.c
+++ b/gdk/x11/gdkdisplay-x11.c
@@ -994,11 +994,21 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
}
if (!is_substructure)
{
- if (surface->x != event->configure.x ||
- surface->y != event->configure.y)
+ int new_abs_x, new_abs_y;
+
+ new_abs_x = event->configure.x;
+ new_abs_y = event->configure.y;
+
+ surface_impl->abs_x = new_abs_x;
+ surface_impl->abs_y = new_abs_y;
+
+ if (surface->parent)
{
- surface->x = event->configure.x;
- surface->y = event->configure.y;
+ GdkX11Surface *parent_impl =
+ GDK_X11_SURFACE (surface->parent);
+
+ surface->x = new_abs_x - parent_impl->abs_x;
+ surface->y = new_abs_y - parent_impl->abs_y;
}
if (surface_impl->unscaled_width != xevent->xconfigure.width ||
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]