[gtk/fix-3728-3799: 1/2] GDK-Win32: Force toplevel surfaces to configure as needed
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/fix-3728-3799: 1/2] GDK-Win32: Force toplevel surfaces to configure as needed
- Date: Thu, 1 Jul 2021 11:33:32 +0000 (UTC)
commit b154f9fe522365049f9ea8e8b9a0efb67504cba4
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, or it is being
minimized.
This fixes issues #3799 and #3728.
gdk/win32/gdkevents-win32.c | 19 ++++++++++++++-----
gdk/win32/gdksurface-win32.c | 35 ++++++++++++++++++++++++++++++++++-
gdk/win32/gdksurface-win32.h | 1 +
3 files changed, 49 insertions(+), 6 deletions(-)
---
diff --git a/gdk/win32/gdkevents-win32.c b/gdk/win32/gdkevents-win32.c
index 808354c4ae..2be0aac319 100644
--- a/gdk/win32/gdkevents-win32.c
+++ b/gdk/win32/gdkevents-win32.c
@@ -2807,6 +2807,7 @@ gdk_event_translate (MSG *msg,
GdkToplevelState set_bits, unset_bits, old_state, new_state;
old_state = window->state;
+ impl = GDK_WIN32_SURFACE (window);
set_bits = 0;
unset_bits = 0;
@@ -2822,13 +2823,21 @@ gdk_event_translate (MSG *msg,
unset_bits |= GDK_TOPLEVEL_STATE_MAXIMIZED;
/*
- * If we are minizing, pause all surface layout computations, and re-start the
- * computation once we are coming out of a minimized state
+ * If we are minizing, pause all surface layout computations.
+ * Once we are coming out of the minimized state,
+ * gdk_toplevel_present() will reenable the layout computations
+ * for us.
*/
- if (!(old_state & GDK_TOPLEVEL_STATE_MINIMIZED) && set_bits & GDK_TOPLEVEL_STATE_MINIMIZED)
- gdk_surface_freeze_updates (window);
+ 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;
+ gdk_surface_freeze_updates (window);
+ }
- if (old_state & GDK_TOPLEVEL_STATE_MINIMIZED && unset_bits & GDK_TOPLEVEL_STATE_MINIMIZED)
+ if (old_state & GDK_TOPLEVEL_STATE_MINIMIZED &&
+ unset_bits & GDK_TOPLEVEL_STATE_MINIMIZED)
gdk_surface_thaw_updates (window);
gdk_surface_set_is_mapped (window, !!IsWindowVisible (msg->hwnd));
diff --git a/gdk/win32/gdksurface-win32.c b/gdk/win32/gdksurface-win32.c
index bca73c6edb..e9da5f6701 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,14 @@ _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 and it
+ * was not minimized.
+ */
+ if (impl->toplevel_force_resize)
+ impl->drag_move_resize_context.native_move_resize_pending = TRUE;
}
else if (GDK_IS_POPUP (surface))
{
@@ -4593,7 +4626,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 +4980,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]