[gtk+] wayland: Postpone processing move_to_rect params until showing



commit cc019de6a5c77a7fc3a291de9f25659e76ac7e4f
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Mon Aug 8 15:00:42 2016 +0800

    wayland: Postpone processing move_to_rect params until showing
    
    At the time of move_to_rect() is called, not all state may have been set
    up on the impl gdk window, causing the position to sometimes be
    slightly offset due to drap shadow margins. For now, work around this
    by postponing the processing of the move_to_rect() parameters until
    showing, when its more likely that all state (such as shadow margin)
    has been set correctly.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=769402

 gdk/wayland/gdkwindow-wayland.c |   53 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 53 insertions(+), 0 deletions(-)
---
diff --git a/gdk/wayland/gdkwindow-wayland.c b/gdk/wayland/gdkwindow-wayland.c
index 193d8cd..e267294 100644
--- a/gdk/wayland/gdkwindow-wayland.c
+++ b/gdk/wayland/gdkwindow-wayland.c
@@ -126,6 +126,7 @@ struct _GdkWindowImplWayland
   unsigned int pending_commit : 1;
   unsigned int awaiting_frame : 1;
   unsigned int position_set : 1;
+  unsigned int moved_to_rect : 1;
   GdkWindowTypeHint hint;
   GdkWindow *transient_for;
 
@@ -172,6 +173,15 @@ struct _GdkWindowImplWayland
   int saved_height;
 
   gulong parent_surface_committed_handler;
+
+  struct {
+    GdkRectangle rect;
+    GdkGravity rect_anchor;
+    GdkGravity window_anchor;
+    GdkAnchorHints anchor_hints;
+    gint rect_anchor_dx;
+    gint rect_anchor_dy;
+  } pending_move_to_rect;
 };
 
 struct _GdkWindowImplWaylandClass
@@ -1702,6 +1712,20 @@ gdk_wayland_window_show (GdkWindow *window,
 {
   GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
 
+  if (impl->moved_to_rect)
+    {
+      GdkWindowImplClass *impl_class =
+        GDK_WINDOW_IMPL_CLASS (_gdk_window_impl_wayland_parent_class);
+
+      impl_class->move_to_rect (window,
+                                &impl->pending_move_to_rect.rect,
+                                impl->pending_move_to_rect.rect_anchor,
+                                impl->pending_move_to_rect.window_anchor,
+                                impl->pending_move_to_rect.anchor_hints,
+                                impl->pending_move_to_rect.rect_anchor_dx,
+                                impl->pending_move_to_rect.rect_anchor_dy);
+    }
+
   if (!impl->display_server.wl_surface)
     gdk_wayland_window_create_surface (window);
 
@@ -1916,6 +1940,7 @@ gdk_window_wayland_move_resize (GdkWindow *window,
           window->x = x;
           window->y = y;
           impl->position_set = 1;
+          impl->moved_to_rect = 0;
 
           if (impl->display_server.wl_subsurface)
             {
@@ -1933,6 +1958,33 @@ gdk_window_wayland_move_resize (GdkWindow *window,
 }
 
 static void
+gdk_window_wayland_move_to_rect (GdkWindow          *window,
+                                 const GdkRectangle *rect,
+                                 GdkGravity          rect_anchor,
+                                 GdkGravity          window_anchor,
+                                 GdkAnchorHints      anchor_hints,
+                                 gint                rect_anchor_dx,
+                                 gint                rect_anchor_dy)
+{
+  GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
+
+  /*
+   * Various state (such as the shadow margin) may be incorrect at this point,
+   * so wait until showing before actually trying to move according to the
+   * anchors and hints.
+   */
+
+  impl->moved_to_rect = 1;
+
+  impl->pending_move_to_rect.rect = *rect;
+  impl->pending_move_to_rect.rect_anchor = rect_anchor;
+  impl->pending_move_to_rect.window_anchor = window_anchor;
+  impl->pending_move_to_rect.anchor_hints = anchor_hints;
+  impl->pending_move_to_rect.rect_anchor_dx = rect_anchor_dx;
+  impl->pending_move_to_rect.rect_anchor_dy = rect_anchor_dy;
+}
+
+static void
 gdk_window_wayland_set_background (GdkWindow       *window,
                                    cairo_pattern_t *pattern)
 {
@@ -2832,6 +2884,7 @@ _gdk_window_impl_wayland_class_init (GdkWindowImplWaylandClass *klass)
   impl_class->restack_under = gdk_window_wayland_restack_under;
   impl_class->restack_toplevel = gdk_window_wayland_restack_toplevel;
   impl_class->move_resize = gdk_window_wayland_move_resize;
+  impl_class->move_to_rect = gdk_window_wayland_move_to_rect;
   impl_class->set_background = gdk_window_wayland_set_background;
   impl_class->reparent = gdk_window_wayland_reparent;
   impl_class->set_device_cursor = gdk_window_wayland_set_device_cursor;


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