[gtk/gtk-4-6] Merge branch 'sumibi-yakitori/fix-minimize-window-macos' into 'main'



commit d468dd2f3b69a97d19a728d7818f92364698c663
Author: Christian Hergert <christian hergert me>
Date:   Mon Apr 4 18:53:19 2022 +0000

    Merge branch 'sumibi-yakitori/fix-minimize-window-macos' into 'main'
    
    macos: Fix problem that window cannot be minimized by user operation
    
    Closes #4811
    
    See merge request GNOME/gtk!4613
    
    (cherry picked from commit d75147db0acd7723732790155fd3a63688193c63)
    
    d3cf7088 macos: Skip running `showAndMakeKey` when a window is minimized by user action

 gdk/macos/gdkmacosdisplay.c         |  3 ++-
 gdk/macos/gdkmacostoplevelsurface.c | 15 +++++++++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)
---
diff --git a/gdk/macos/gdkmacosdisplay.c b/gdk/macos/gdkmacosdisplay.c
index d85a744563..41be42cfbe 100644
--- a/gdk/macos/gdkmacosdisplay.c
+++ b/gdk/macos/gdkmacosdisplay.c
@@ -434,7 +434,8 @@ select_key_in_idle_cb (gpointer data)
         {
           GdkMacosSurface *surface = iter->data;
 
-          if (GDK_SURFACE_IS_MAPPED (GDK_SURFACE (surface)))
+          if (GDK_SURFACE_IS_MAPPED (GDK_SURFACE (surface)) &&
+              ([surface->window styleMask] & NSWindowStyleMaskMiniaturizable) == 0)
             {
               [surface->window showAndMakeKey:YES];
               break;
diff --git a/gdk/macos/gdkmacostoplevelsurface.c b/gdk/macos/gdkmacostoplevelsurface.c
index aa828fcfa5..54bc4c8af9 100644
--- a/gdk/macos/gdkmacostoplevelsurface.c
+++ b/gdk/macos/gdkmacostoplevelsurface.c
@@ -82,6 +82,19 @@ _gdk_macos_toplevel_surface_unmaximize (GdkMacosToplevelSurface *self)
     [window zoom:window];
 }
 
+static void
+_gdk_macos_toplevel_surface_unminimize (GdkMacosToplevelSurface *self)
+{
+  NSWindow *window;
+
+  g_assert (GDK_IS_MACOS_TOPLEVEL_SURFACE (self));
+
+  window = _gdk_macos_surface_get_native (GDK_MACOS_SURFACE (self));
+
+  if ([window isMiniaturized])
+    [window deminiaturize:window];
+}
+
 static void
 _gdk_macos_toplevel_surface_present (GdkToplevel       *toplevel,
                                      GdkToplevelLayout *layout)
@@ -202,6 +215,8 @@ _gdk_macos_toplevel_surface_present (GdkToplevel       *toplevel,
         _gdk_macos_toplevel_surface_unfullscreen (self);
     }
 
+  _gdk_macos_toplevel_surface_unminimize (self);
+
   if (!GDK_MACOS_SURFACE (self)->did_initial_present)
     {
       int x = 0, y = 0;


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