[gtk/fix-3728-3799: 1/2] GDK-Win32: Force toplevel surfaces to configure as needed




commit 7be23068dc23295ef7f124ee28190bbab50131a0
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Thu Jul 1 18:21:29 2021 +0800

    GDK-Win32: Force toplevel surfaces to configure as needed
    
    If the toplevel surface has already been initially created and
    presented, ensure that it will always undergo configuration for sizing,
    unless that surface underwent an AeroSnap operation.
    
    This fixes issues #3799 and #3728.

 gdk/win32/gdksurface-win32.c | 34 +++++++++++++++++++++++++++++++++-
 gdk/win32/gdksurface-win32.h |  1 +
 2 files changed, 34 insertions(+), 1 deletion(-)
---
diff --git a/gdk/win32/gdksurface-win32.c b/gdk/win32/gdksurface-win32.c
index bca73c6edb..de1568e3e4 100644
--- a/gdk/win32/gdksurface-win32.c
+++ b/gdk/win32/gdksurface-win32.c
@@ -2205,6 +2205,12 @@ unsnap (GdkSurface  *window,
 
   GDK_NOTE (MISC, g_print ("Unsnapped window size %d x %d @ %d : %d\n", rect.width, rect.height, rect.x, 
rect.y));
 
+  if (GDK_IS_TOPLEVEL (window))
+    {
+      impl->drag_move_resize_context.native_move_resize_pending = FALSE;
+      impl->toplevel_force_resize = FALSE;
+    }
+
   gdk_win32_surface_move_resize (window, rect.x, rect.y,
                                  rect.width, rect.height);
 
@@ -2319,6 +2325,12 @@ snap_up (GdkSurface *window)
    */
   compute_toplevel_size (window, TRUE, &width, &height);
 
+  if (GDK_IS_TOPLEVEL (window))
+    {
+      impl->drag_move_resize_context.native_move_resize_pending = FALSE;
+      impl->toplevel_force_resize = FALSE;
+    }
+
   gdk_win32_surface_move_resize (window, x, y, width, height);
 }
 
@@ -2345,6 +2357,12 @@ snap_left (GdkSurface  *window,
   rect.width = rect.width + impl->shadow_x;
   rect.height = rect.height + impl->shadow_y;
 
+  if (GDK_IS_TOPLEVEL (window))
+    {
+      impl->drag_move_resize_context.native_move_resize_pending = FALSE;
+      impl->toplevel_force_resize = FALSE;
+    }
+
   gdk_win32_surface_move_resize (window,
                                  rect.x, rect.y,
                                  rect.width, rect.height);
@@ -2374,6 +2392,12 @@ snap_right (GdkSurface  *window,
   rect.width = rect.width + impl->shadow_x;
   rect.height = rect.height + impl->shadow_y;
 
+  if (GDK_IS_TOPLEVEL (window))
+    {
+      impl->drag_move_resize_context.native_move_resize_pending = FALSE;
+      impl->toplevel_force_resize = FALSE;
+    }
+
   gdk_win32_surface_move_resize (window,
                                  rect.x, rect.y,
                                  rect.width, rect.height);
@@ -4563,6 +4587,7 @@ _gdk_win32_surface_request_layout (GdkSurface *surface)
     {
       _gdk_win32_get_window_rect (surface, &rect);
 
+      impl->next_layout.configured_rect = rect;
       impl->next_layout.configured_width = (rect.right - rect.left + scale - 1) / scale;
       impl->next_layout.configured_height = (rect.bottom - rect.top + scale - 1) / scale;
 
@@ -4570,6 +4595,13 @@ _gdk_win32_surface_request_layout (GdkSurface *surface)
         {
           surface->x = rect.left / scale;
           surface->y = rect.top / scale;
+
+          /*
+           * We force a resize of the toplevel if it is not just created/
+           * presented and it did not just undergo an AeroSnap op
+           */
+          if (impl->toplevel_force_resize)
+            impl->drag_move_resize_context.native_move_resize_pending = TRUE;
         }
       else if (GDK_IS_POPUP (surface))
         {
@@ -4593,7 +4625,6 @@ _gdk_win32_surface_compute_size (GdkSurface *surface)
     {
       surface->width = impl->next_layout.configured_width;
       surface->height = impl->next_layout.configured_height;
-
       _gdk_surface_update_size (surface);
     }
 
@@ -4948,6 +4979,7 @@ gdk_win32_toplevel_present (GdkToplevel       *toplevel,
 
   gdk_win32_surface_show (surface, FALSE);
   maybe_notify_mapped (surface);
+  impl->toplevel_force_resize = TRUE;
 }
 
 static gboolean
diff --git a/gdk/win32/gdksurface-win32.h b/gdk/win32/gdksurface-win32.h
index 5f85c50373..2e29427a4f 100644
--- a/gdk/win32/gdksurface-win32.h
+++ b/gdk/win32/gdksurface-win32.h
@@ -337,6 +337,7 @@ struct _GdkWin32Surface
   int surface_scale;
 
   GdkToplevelLayout *toplevel_layout;
+  gboolean toplevel_force_resize;
   struct {
     int configured_width;
     int configured_height;


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