macos: Skip running showAndMakeKey when a window is minimized by user action

When a window is minimized by user action, the `showAndMakeKey` method is not executed when idle. This prevents the window from being un-minimized immediately.
And allow programmatic minimization of a window by un-minimizing them in `_gdk_macos_toplevel_surface_present`

Closes #4811
This commit is contained in:
sumibi-yakitori 2022-04-02 21:29:27 +09:00
parent d1ce514260
commit d3cf7088b3
2 changed files with 17 additions and 1 deletions

View File

@ -434,7 +434,8 @@ select_key_in_idle_cb (gpointer data)
{ {
GdkMacosSurface *surface = iter->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]; [surface->window showAndMakeKey:YES];
break; break;

View File

@ -82,6 +82,19 @@ _gdk_macos_toplevel_surface_unmaximize (GdkMacosToplevelSurface *self)
[window zoom:window]; [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 static void
_gdk_macos_toplevel_surface_present (GdkToplevel *toplevel, _gdk_macos_toplevel_surface_present (GdkToplevel *toplevel,
GdkToplevelLayout *layout) GdkToplevelLayout *layout)
@ -202,6 +215,8 @@ _gdk_macos_toplevel_surface_present (GdkToplevel *toplevel,
_gdk_macos_toplevel_surface_unfullscreen (self); _gdk_macos_toplevel_surface_unfullscreen (self);
} }
_gdk_macos_toplevel_surface_unminimize (self);
if (!GDK_MACOS_SURFACE (self)->did_initial_present) if (!GDK_MACOS_SURFACE (self)->did_initial_present)
{ {
int x = 0, y = 0; int x = 0, y = 0;