summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Hergert <christian@hergert.me>2022-03-02 00:47:27 -0800
committerChristian Hergert <chergert@redhat.com>2022-03-16 12:25:09 -0700
commit2961cc44c50e431bc56336d6b5492d8a39424b0c (patch)
tree4d37d857fcdb419ce160c3f677bdcafad139b002
parent46da364289b2ce8aabe96b364f721944dbe3c90e (diff)
downloadgtk+-2961cc44c50e431bc56336d6b5492d8a39424b0c.tar.gz
macos: move children when monitor changes
We can rely on other code to move monitors, but specifically with children we want to try harder to move them as a group and keep positioning in tact.
-rw-r--r--gdk/macos/gdkmacossurface.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/gdk/macos/gdkmacossurface.c b/gdk/macos/gdkmacossurface.c
index c3916cdc88..bca3c9210a 100644
--- a/gdk/macos/gdkmacossurface.c
+++ b/gdk/macos/gdkmacossurface.c
@@ -1060,6 +1060,7 @@ _gdk_macos_surface_monitor_changed (GdkMacosSurface *self)
self->in_change_monitor = TRUE;
_gdk_macos_surface_cancel_frame (self);
+ _gdk_macos_surface_configure (self);
rect.x = self->root_x;
rect.y = self->root_y;
@@ -1123,9 +1124,39 @@ _gdk_macos_surface_monitor_changed (GdkMacosSurface *self)
g_message ("Surface \"%s\" moved to monitor \"%s\"",
self->title ? self->title : "unknown",
gdk_monitor_get_connector (best)));
+
+ _gdk_macos_surface_configure (self);
+
+ if (GDK_SURFACE_IS_MAPPED (GDK_SURFACE (self)))
+ {
+ _gdk_macos_surface_request_frame (self);
+ gdk_surface_request_layout (GDK_SURFACE (self));
+ }
+
+ for (const GList *iter = GDK_SURFACE (self)->children;
+ iter != NULL;
+ iter = iter->next)
+ {
+ GdkMacosSurface *child = iter->data;
+ GdkRectangle area;
+
+ g_set_object (&child->best_monitor, best);
+
+ area.x = self->root_x + GDK_SURFACE (child)->x + child->shadow_left;
+ area.y = self->root_y + GDK_SURFACE (child)->y + child->shadow_top;
+ area.width = GDK_SURFACE (child)->width - child->shadow_left - child->shadow_right;
+ area.height = GDK_SURFACE (child)->height - child->shadow_top - child->shadow_bottom;
+
+ _gdk_macos_monitor_clamp (GDK_MACOS_MONITOR (best), &area);
+
+ area.x -= child->shadow_left;
+ area.y -= child->shadow_top;
+
+ _gdk_macos_surface_move (child, area.x, area.y);
+ gdk_surface_invalidate_rect (GDK_SURFACE (child), NULL);
+ }
}
- _gdk_macos_surface_configure (self);
gdk_surface_invalidate_rect (GDK_SURFACE (self), NULL);
self->in_change_monitor = FALSE;