[gtk+] wayland: Use helper to translate to real parent window geometry



commit 74d237df410f850e31d5d20e0380ca3ad1caf766
Author: Jonas Ådahl <jadahl gmail com>
Date:   Mon Sep 12 18:39:06 2016 +0800

    wayland: Use helper to translate to real parent window geometry
    
    Use a helper to translate a coordinate from non-real GdkWindow parent
    to window geometry coordinate space of the real GdkWindow parent,
    meaning the coordinate space of the GdkWindow of the parent used as a
    xdg_popup parent where (0, 0) is inside of the shadow margin.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=771117

 gdk/wayland/gdkwindow-wayland.c |   24 ++++++++++++++++++------
 1 files changed, 18 insertions(+), 6 deletions(-)
---
diff --git a/gdk/wayland/gdkwindow-wayland.c b/gdk/wayland/gdkwindow-wayland.c
index 4614d48..17cfed5 100644
--- a/gdk/wayland/gdkwindow-wayland.c
+++ b/gdk/wayland/gdkwindow-wayland.c
@@ -1627,6 +1627,19 @@ get_real_parent_and_translate (GdkWindow *window,
 }
 
 static void
+translate_to_real_parent_window_geometry (GdkWindow  *window,
+                                          gint       *x,
+                                          gint       *y)
+{
+  GdkWindow *parent;
+
+  parent = get_real_parent_and_translate (window, x, y);
+
+  *x -= parent->shadow_left;
+  *y -= parent->shadow_top;
+}
+
+static void
 calculate_popup_rect (GdkWindow    *window,
                       GdkGravity    rect_anchor,
                       GdkGravity    window_anchor,
@@ -1879,7 +1892,6 @@ create_dynamic_positioner (GdkWindow *window)
   GdkWaylandDisplay *display =
     GDK_WAYLAND_DISPLAY (gdk_window_get_display (window));
   struct zxdg_positioner_v6 *positioner;
-  GdkWindow *parent;
   GdkRectangle geometry;
   enum zxdg_positioner_v6_anchor anchor;
   enum zxdg_positioner_v6_anchor gravity;
@@ -1894,15 +1906,15 @@ create_dynamic_positioner (GdkWindow *window)
 
   real_anchor_rect_x = impl->pending_move_to_rect.rect.x;
   real_anchor_rect_y = impl->pending_move_to_rect.rect.y;
-  parent = get_real_parent_and_translate (window,
-                                          &real_anchor_rect_x,
-                                          &real_anchor_rect_y);
+  translate_to_real_parent_window_geometry (window,
+                                            &real_anchor_rect_x,
+                                            &real_anchor_rect_y);
 
   anchor_rect_width = impl->pending_move_to_rect.rect.width;
   anchor_rect_height = impl->pending_move_to_rect.rect.height;
   zxdg_positioner_v6_set_anchor_rect (positioner,
-                                      real_anchor_rect_x - parent->shadow_left,
-                                      real_anchor_rect_y - parent->shadow_top,
+                                      real_anchor_rect_x,
+                                      real_anchor_rect_y,
                                       anchor_rect_width,
                                       anchor_rect_height);
 


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