[gtk/wip/chergert/for-4-6: 34/56] macos: handle transient-for from configure




commit cb99370ce4b2af715c2b6debf3e54a4bf2d9a2fb
Author: Christian Hergert <christian hergert me>
Date:   Wed Mar 2 00:43:33 2022 -0800

    macos: handle transient-for from configure
    
    We failed to handle the toplevel with transient-for case here which could
    cause our X/Y calculations to be off in other areas such as best monitor
    detection.

 gdk/macos/gdkmacossurface.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/gdk/macos/gdkmacossurface.c b/gdk/macos/gdkmacossurface.c
index 8a1cf3747f..92d6cd1c34 100644
--- a/gdk/macos/gdkmacossurface.c
+++ b/gdk/macos/gdkmacossurface.c
@@ -811,8 +811,9 @@ _gdk_macos_surface_update_fullscreen_state (GdkMacosSurface *self)
 void
 _gdk_macos_surface_configure (GdkMacosSurface *self)
 {
-  GdkMacosDisplay *display;
   GdkSurface *surface = (GdkSurface *)self;
+  GdkMacosDisplay *display;
+  GdkMacosSurface *parent;
   NSRect frame_rect;
   NSRect content_rect;
 
@@ -821,6 +822,13 @@ _gdk_macos_surface_configure (GdkMacosSurface *self)
   if (GDK_SURFACE_DESTROYED (self))
     return;
 
+  if (surface->parent != NULL)
+    parent = GDK_MACOS_SURFACE (surface->parent);
+  else if (surface->transient_for != NULL)
+    parent = GDK_MACOS_SURFACE (surface->transient_for);
+  else
+    parent = NULL;
+
   display = GDK_MACOS_DISPLAY (GDK_SURFACE (self)->display);
   frame_rect = [self->window frame];
   content_rect = [self->window contentRectForFrameRect:frame_rect];
@@ -830,10 +838,10 @@ _gdk_macos_surface_configure (GdkMacosSurface *self)
                                           content_rect.origin.y + content_rect.size.height,
                                           &self->root_x, &self->root_y);
 
-  if (surface->parent != NULL)
+  if (parent != NULL)
     {
-      surface->x = self->root_x - GDK_MACOS_SURFACE (surface->parent)->root_x;
-      surface->y = self->root_y - GDK_MACOS_SURFACE (surface->parent)->root_y;
+      surface->x = self->root_x - parent->root_x;
+      surface->y = self->root_y - parent->root_y;
     }
   else
     {


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