[gtk/fix-3728-3799: 132/132] GDK-Win32: Make surface ready for updates




commit 1350dbe7f0d63d65a1ee457ae0f41e986d24776c
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Thu Jul 29 18:35:08 2021 +0800

    GDK-Win32: Make surface ready for updates
    
    Make the surface respond to size computations unless it is just being created,
    or just maximized, made fullscreen or just undergoes an AeroSnap operation.
    
    This will ensure that the surface size is properly computed in time.
    
    This will fix issues 3728 and 3799.

 gdk/win32/gdksurface-win32.c | 58 +++++++++++++++++++++++++++++++++++++++++---
 gdk/win32/gdksurface-win32.h |  1 +
 2 files changed, 56 insertions(+), 3 deletions(-)
---
diff --git a/gdk/win32/gdksurface-win32.c b/gdk/win32/gdksurface-win32.c
index 4c1f7c1a3f..b6d012ac24 100644
--- a/gdk/win32/gdksurface-win32.c
+++ b/gdk/win32/gdksurface-win32.c
@@ -656,6 +656,7 @@ _gdk_win32_display_create_surface (GdkDisplay     *display,
 
   g_object_unref (frame_clock);
   impl->hdc = GetDC (impl->handle);
+  impl->inhibit_configure = TRUE;
 
   return surface;
 }
@@ -1097,7 +1098,8 @@ gdk_win32_surface_resize (GdkSurface *window,
                            SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER));
   window->resize_count += 1;
 
-  gdk_surface_request_layout (window);
+  if (!GDK_WIN32_SURFACE (window)->force_recompute_size)
+    gdk_surface_request_layout (window);
 }
 
 static void
@@ -2130,6 +2132,12 @@ discard_snapinfo (GdkSurface *window)
 
   impl->snap_state = GDK_WIN32_AEROSNAP_STATE_UNDETERMINED;
 
+  if (impl->inhibit_configure)
+    {
+      impl->inhibit_configure = FALSE;
+      impl->force_recompute_size = TRUE;
+    }
+
   if (impl->snap_stash == NULL)
     return;
 
@@ -2148,6 +2156,12 @@ unsnap (GdkSurface  *window,
 
   impl->snap_state = GDK_WIN32_AEROSNAP_STATE_UNDETERMINED;
 
+  if (impl->inhibit_configure)
+    {
+      impl->inhibit_configure = FALSE;
+      impl->force_recompute_size = TRUE;
+    }
+
   if (impl->snap_stash == NULL)
     return;
 
@@ -2543,6 +2557,12 @@ apply_snap (GdkSurface             *window,
       snap_up (window);
       break;
     }
+
+  if (snap != GDK_WIN32_AEROSNAP_STATE_UNDETERMINED)
+    {
+      GDK_WIN32_SURFACE (window)->inhibit_configure = TRUE;
+      GDK_WIN32_SURFACE (window)->force_recompute_size = FALSE;
+    }
 }
 
 /* Registers a dumb window class. This window
@@ -4125,6 +4145,8 @@ gdk_win32_surface_maximize (GdkSurface *window)
                           _gdk_win32_surface_state_to_string (window->state)));
 
   impl = GDK_WIN32_SURFACE (window);
+  impl->inhibit_configure = TRUE;
+  impl->force_recompute_size = FALSE;
 
   if (GDK_SURFACE_IS_MAPPED (window))
     GtkShowWindow (window, SW_MAXIMIZE);
@@ -4137,6 +4159,8 @@ gdk_win32_surface_maximize (GdkSurface *window)
 static void
 gdk_win32_surface_unmaximize (GdkSurface *window)
 {
+  GdkWin32Surface *impl;
+
   g_return_if_fail (GDK_IS_SURFACE (window));
 
   if (GDK_SURFACE_DESTROYED (window))
@@ -4154,6 +4178,14 @@ gdk_win32_surface_unmaximize (GdkSurface *window)
     gdk_synthesize_surface_state (window,
                                 GDK_TOPLEVEL_STATE_MAXIMIZED,
                                 0);
+
+  impl = GDK_WIN32_SURFACE (window);
+
+  if (impl->inhibit_configure)
+    {
+      impl->inhibit_configure = FALSE;
+      impl->force_recompute_size = TRUE;
+    }
 }
 
 static void
@@ -4578,6 +4610,16 @@ _gdk_win32_surface_request_layout (GdkSurface *surface)
                                          &surface->x, &surface->y,
                                           NULL, NULL);
         }
+
+      if (!impl->inhibit_configure)
+        impl->force_recompute_size = TRUE;
+      else
+        {
+          if (surface->state & GDK_TOPLEVEL_STATE_FULLSCREEN ||
+              surface->state & GDK_TOPLEVEL_STATE_MAXIMIZED ||
+              impl->snap_state != GDK_WIN32_AEROSNAP_STATE_UNDETERMINED)
+            impl->inhibit_configure = FALSE;
+        }
     }
 }
 
@@ -4592,8 +4634,18 @@ _gdk_win32_surface_compute_size (GdkSurface *surface)
 
   if (!impl->drag_move_resize_context.native_move_resize_pending)
     {
-      surface->width = impl->next_layout.configured_width;
-      surface->height = impl->next_layout.configured_height;
+      if (GDK_IS_TOPLEVEL (surface) && impl->force_recompute_size)
+        {
+          surface->width = width;
+          surface->height = height;
+          gdk_win32_surface_resize (surface, width, height);
+          impl->force_recompute_size = FALSE;
+        }
+      else
+        {
+          surface->width = impl->next_layout.configured_width;
+          surface->height = impl->next_layout.configured_height;
+        }
 
       _gdk_surface_update_size (surface);
     }
diff --git a/gdk/win32/gdksurface-win32.h b/gdk/win32/gdksurface-win32.h
index 6ac1d6a059..d6c5a9bb1f 100644
--- a/gdk/win32/gdksurface-win32.h
+++ b/gdk/win32/gdksurface-win32.h
@@ -342,6 +342,7 @@ struct _GdkWin32Surface
     int configured_height;
     RECT configured_rect;
   } next_layout;
+  gboolean force_recompute_size;
 
 #ifdef GDK_WIN32_ENABLE_EGL
   EGLSurface egl_surface;


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