[gtk/wip.win32.fixes: 145/151] gdksurface-win32.c: Fix maximize and fullscreen




commit cccbc84533be2244db0db1f09defdd715eadb0f7
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Fri Jul 2 11:19:49 2021 +0800

    gdksurface-win32.c: Fix maximize and fullscreen
    
    We need to stop requesting for configuring when we are maximizing the
    toplevel surface, or when we are making the it fullscreen, otherwise things
    break due to the previous updates.  We must also check the toplevel surface
    state to do likewise when it is in maximized or fullscreen mode.
    
    Also go back to using inhibit_configure instead of a new gboolean in
    GdkWin32Surface.

 gdk/win32/gdkevents-win32.c  |  8 +++++---
 gdk/win32/gdksurface-win32.c | 39 +++++++++++++++++++++++++++++++--------
 gdk/win32/gdksurface-win32.h |  1 -
 3 files changed, 36 insertions(+), 12 deletions(-)
---
diff --git a/gdk/win32/gdkevents-win32.c b/gdk/win32/gdkevents-win32.c
index 2be0aac319..77051a9739 100644
--- a/gdk/win32/gdkevents-win32.c
+++ b/gdk/win32/gdkevents-win32.c
@@ -2831,14 +2831,16 @@ gdk_event_translate (MSG *msg,
       if (!(old_state & GDK_TOPLEVEL_STATE_MINIMIZED) &&
           set_bits & GDK_TOPLEVEL_STATE_MINIMIZED)
         {
-          impl->drag_move_resize_context.native_move_resize_pending = FALSE;
-          impl->toplevel_force_resize = FALSE;
+          impl->inhibit_configure = TRUE;
           gdk_surface_freeze_updates (window);
         }
 
       if (old_state & GDK_TOPLEVEL_STATE_MINIMIZED &&
           unset_bits & GDK_TOPLEVEL_STATE_MINIMIZED)
-        gdk_surface_thaw_updates (window);
+        {
+          impl->inhibit_configure = FALSE;
+          gdk_surface_thaw_updates (window);
+        }
 
          gdk_surface_set_is_mapped (window, !!IsWindowVisible (msg->hwnd));
          gdk_synthesize_surface_state (window, unset_bits, set_bits);
diff --git a/gdk/win32/gdksurface-win32.c b/gdk/win32/gdksurface-win32.c
index 63b777038b..6325c31f58 100644
--- a/gdk/win32/gdksurface-win32.c
+++ b/gdk/win32/gdksurface-win32.c
@@ -568,6 +568,7 @@ _gdk_win32_display_create_surface (GdkDisplay     *display,
       /* We initially place it at default so that we can get the
          default window positioning if we want */
       window_x = window_y = CW_USEDEFAULT;
+      impl->inhibit_configure = TRUE;
     }
   else
     {
@@ -2138,7 +2139,7 @@ discard_snapinfo (GdkSurface *window)
 }
 
 static void
-unsnap (GdkSurface  *window,
+unsnap (GdkSurface *window,
         GdkMonitor *monitor)
 {
   GdkWin32Surface *impl;
@@ -2210,7 +2211,7 @@ unsnap (GdkSurface  *window,
   if (GDK_IS_TOPLEVEL (window))
     {
       impl->drag_move_resize_context.native_move_resize_pending = FALSE;
-      impl->toplevel_force_resize = FALSE;
+      impl->inhibit_configure = TRUE;
     }
 
   gdk_win32_surface_move_resize (window, rect.x, rect.y,
@@ -2330,7 +2331,7 @@ snap_up (GdkSurface *window)
   if (GDK_IS_TOPLEVEL (window))
     {
       impl->drag_move_resize_context.native_move_resize_pending = FALSE;
-      impl->toplevel_force_resize = FALSE;
+      impl->inhibit_configure = TRUE;
     }
 
   gdk_win32_surface_move_resize (window, x, y, width, height);
@@ -2362,7 +2363,7 @@ snap_left (GdkSurface  *window,
   if (GDK_IS_TOPLEVEL (window))
     {
       impl->drag_move_resize_context.native_move_resize_pending = FALSE;
-      impl->toplevel_force_resize = FALSE;
+      impl->inhibit_configure = TRUE;
     }
 
   gdk_win32_surface_move_resize (window,
@@ -2397,7 +2398,7 @@ snap_right (GdkSurface  *window,
   if (GDK_IS_TOPLEVEL (window))
     {
       impl->drag_move_resize_context.native_move_resize_pending = FALSE;
-      impl->toplevel_force_resize = FALSE;
+      impl->inhibit_configure = TRUE;
     }
 
   gdk_win32_surface_move_resize (window,
@@ -4156,11 +4157,16 @@ gdk_win32_surface_maximize (GdkSurface *window)
     gdk_synthesize_surface_state (window,
                                 0,
                                 GDK_TOPLEVEL_STATE_MAXIMIZED);
+
+  impl->inhibit_configure = TRUE;
+  impl->drag_move_resize_context.native_move_resize_pending = FALSE;
 }
 
 static void
 gdk_win32_surface_unmaximize (GdkSurface *window)
 {
+  GdkWin32Surface *impl;
+
   g_return_if_fail (GDK_IS_SURFACE (window));
 
   if (GDK_SURFACE_DESTROYED (window))
@@ -4178,6 +4184,10 @@ gdk_win32_surface_unmaximize (GdkSurface *window)
     gdk_synthesize_surface_state (window,
                                 GDK_TOPLEVEL_STATE_MAXIMIZED,
                                 0);
+
+  impl = GDK_WIN32_SURFACE (window);
+  impl->inhibit_configure = FALSE;
+  impl->drag_move_resize_context.native_move_resize_pending = TRUE;
 }
 
 static void
@@ -4594,15 +4604,26 @@ _gdk_win32_surface_request_layout (GdkSurface *surface)
 
       if (GDK_IS_TOPLEVEL (surface))
         {
+          gboolean maximize = FALSE;
+
           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 and it
-           * was not minimized.
+           * was not minimized nor minimized nor fullscreen'ed.
            */
-          if (impl->toplevel_force_resize)
+          if (impl->toplevel_layout != NULL)
+            {
+              gdk_toplevel_layout_get_maximized (impl->toplevel_layout,
+                                                &maximize);
+              if (!maximize)
+                gdk_toplevel_layout_get_fullscreen (impl->toplevel_layout,
+                                                   &maximize);
+            }
+
+          if (!impl->inhibit_configure && !maximize)
             impl->drag_move_resize_context.native_move_resize_pending = TRUE;
         }
       else if (GDK_IS_POPUP (surface))
@@ -4980,7 +5001,9 @@ gdk_win32_toplevel_present (GdkToplevel       *toplevel,
 
   gdk_win32_surface_show (surface, FALSE);
   maybe_notify_mapped (surface);
-  impl->toplevel_force_resize = TRUE;
+
+  if (impl->inhibit_configure)
+    impl->inhibit_configure = FALSE;
 }
 
 static gboolean
diff --git a/gdk/win32/gdksurface-win32.h b/gdk/win32/gdksurface-win32.h
index b0895018ca..6ac1d6a059 100644
--- a/gdk/win32/gdksurface-win32.h
+++ b/gdk/win32/gdksurface-win32.h
@@ -337,7 +337,6 @@ 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]