[gtk/wip/chergert/quartz4u] macos: select next main window when resigning main



commit 282d3399a98db30addb9d73ea9a4eabbc683eb46
Author: Christian Hergert <chergert redhat com>
Date:   Mon May 18 21:19:39 2020 -0700

    macos: select next main window when resigning main

 gdk/macos/gdkmacosdisplay.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)
---
diff --git a/gdk/macos/gdkmacosdisplay.c b/gdk/macos/gdkmacosdisplay.c
index dc56e39a84..7507fa1755 100644
--- a/gdk/macos/gdkmacosdisplay.c
+++ b/gdk/macos/gdkmacosdisplay.c
@@ -464,7 +464,7 @@ _gdk_macos_display_surface_removed (GdkMacosDisplay *self,
   g_queue_unlink (&self->sorted_surfaces, &surface->sorted);
 
   if (queue_contains (&self->main_surfaces, &surface->main))
-    g_queue_unlink (&self->main_surfaces, &surface->main);
+    _gdk_macos_display_surface_resigned_main (self, surface);
 
   if (queue_contains (&self->awaiting_frames, &surface->frame))
     g_queue_unlink (&self->awaiting_frames, &surface->frame);
@@ -506,7 +506,6 @@ _gdk_macos_display_surface_resigned_key (GdkMacosDisplay *self,
   g_return_if_fail (GDK_IS_MACOS_DISPLAY (self));
   g_return_if_fail (GDK_IS_MACOS_SURFACE (surface));
 
-
   if (self->keyboard_surface == surface)
     {
       GdkDevice *keyboard;
@@ -520,6 +519,8 @@ _gdk_macos_display_surface_resigned_key (GdkMacosDisplay *self,
     }
 
   self->keyboard_surface = NULL;
+
+  _gdk_macos_display_clear_sorting (self);
 }
 
 void
@@ -541,21 +542,27 @@ void
 _gdk_macos_display_surface_resigned_main (GdkMacosDisplay *self,
                                           GdkMacosSurface *surface)
 {
+  const GList *surfaces;
+
   g_return_if_fail (GDK_IS_MACOS_DISPLAY (self));
   g_return_if_fail (GDK_IS_MACOS_SURFACE (surface));
 
   if (queue_contains (&self->main_surfaces, &surface->main))
     g_queue_unlink (&self->main_surfaces, &surface->main);
 
-  for (const GList *iter = self->main_surfaces.head; iter; iter = iter->next)
+  _gdk_macos_display_clear_sorting (self);
+  surfaces = _gdk_macos_display_get_surfaces (self);
+
+  for (const GList *iter = surfaces; iter; iter = iter->next)
     {
       GdkMacosSurface *new_surface = iter->data;
 
       g_assert (GDK_IS_MACOS_SURFACE (new_surface));
-      g_assert (new_surface != surface);
 
-      if (GDK_SURFACE_IS_MAPPED (GDK_SURFACE (new_surface)) &&
-          GDK_IS_TOPLEVEL (new_surface))
+      if (new_surface == surface)
+        continue;
+
+      if (GDK_SURFACE_IS_MAPPED (GDK_SURFACE (new_surface)))
         {
           NSWindow *nswindow = _gdk_macos_surface_get_native (new_surface);
           [nswindow makeKeyAndOrderFront:nswindow];
@@ -563,8 +570,6 @@ _gdk_macos_display_surface_resigned_main (GdkMacosDisplay *self,
         }
     }
 
-  g_queue_push_tail_link (&self->main_surfaces, &surface->main);
-
   _gdk_macos_display_clear_sorting (self);
 }
 


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