[gtk/wip/chergert/for-main: 4/10] macos: reposition popup children when monitors move




commit c64c86096cbfe8b96810cbed077973c51cee0b79
Author: Christian Hergert <christian hergert me>
Date:   Mon Feb 28 18:17:16 2022 -0800

    macos: reposition popup children when monitors move

 gdk/macos/gdkmacossurface.c | 29 ++++++++++++++++++++++++++---
 1 file changed, 26 insertions(+), 3 deletions(-)
---
diff --git a/gdk/macos/gdkmacossurface.c b/gdk/macos/gdkmacossurface.c
index 233694449b..15c7de5401 100644
--- a/gdk/macos/gdkmacossurface.c
+++ b/gdk/macos/gdkmacossurface.c
@@ -1137,12 +1137,35 @@ _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);
+      gdk_surface_invalidate_rect (GDK_SURFACE (self), NULL);
+
+      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;
+
+          if (!GDK_IS_POPUP (child))
+            continue;
+
+          g_set_object (&child->best_monitor, best);
+
+          _gdk_macos_surface_move (child,
+                                   self->root_x + GDK_SURFACE (child)->x,
+                                   self->root_y + GDK_SURFACE (child)->y);
+          gdk_surface_invalidate_rect (GDK_SURFACE (child), NULL);
+        }
     }
 
   self->in_change_monitor = FALSE;
-  _gdk_macos_surface_configure (self);
-  gdk_surface_invalidate_rect (GDK_SURFACE (self), NULL);
-  _gdk_macos_surface_request_frame (self);
 }
 
 GdkMonitor *


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