[gtk/wip/chergert/for-main] macos: reposition surface when attaching to parent



commit f4d2a28633f4dded55390b3fa40921e53a3c7584
Author: Christian Hergert <christian hergert me>
Date:   Tue Mar 1 00:06:57 2022 -0800

    macos: reposition surface when attaching to parent
    
    This helps improve the initial positioning of windows after attaching them
    to their transient-for parent.

 gdk/macos/gdkmacostoplevelsurface.c | 8 ++++++++
 1 file changed, 8 insertions(+)
---
diff --git a/gdk/macos/gdkmacostoplevelsurface.c b/gdk/macos/gdkmacostoplevelsurface.c
index 956673e89f..1759077563 100644
--- a/gdk/macos/gdkmacostoplevelsurface.c
+++ b/gdk/macos/gdkmacostoplevelsurface.c
@@ -710,13 +710,21 @@ _gdk_macos_toplevel_surface_attach_to_parent (GdkMacosToplevelSurface *self)
     {
       NSWindow *parent = _gdk_macos_surface_get_native (GDK_MACOS_SURFACE (surface->transient_for));
       NSWindow *window = _gdk_macos_surface_get_native (GDK_MACOS_SURFACE (self));
+      int x, y;
 
       [parent addChildWindow:window ordered:NSWindowAbove];
 
       if (GDK_SURFACE (self)->modal_hint)
         [window setLevel:NSModalPanelWindowLevel];
 
+      surface->x = 0;
+      surface->y = 0;
+
       _gdk_macos_display_clear_sorting (GDK_MACOS_DISPLAY (surface->display));
+      _gdk_macos_display_position_surface (GDK_MACOS_DISPLAY (surface->display),
+                                           GDK_MACOS_SURFACE (surface),
+                                           &x, &y);
+      _gdk_macos_surface_move (GDK_MACOS_SURFACE (surface), x, y);
     }
 }
 


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