From: Christian Hergert Date: Thu, 17 Feb 2022 02:26:59 +0000 (-0800) Subject: macos: restore key window after hiding popup X-Git-Tag: archive/raspbian/4.6.5+ds-1+rpi1~1^2~19^2~3^2~72^2~5 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=b2de83efcbf2bf1b97f5c9804ed260199892b7f1;p=gtk4.git macos: restore key window after hiding popup This fixes the focus returning to the parent window after the popup has been hidden in the form of being a "Key Window" in macOS. --- diff --git a/gdk/macos/gdkmacossurface.c b/gdk/macos/gdkmacossurface.c index cc7bbd9b9b..5404d1e3b8 100644 --- a/gdk/macos/gdkmacossurface.c +++ b/gdk/macos/gdkmacossurface.c @@ -133,6 +133,7 @@ gdk_macos_surface_hide (GdkSurface *surface) GdkMacosSurface *self = (GdkMacosSurface *)surface; GdkSeat *seat; gboolean was_mapped; + gboolean was_key; g_assert (GDK_IS_MACOS_SURFACE (self)); @@ -141,6 +142,7 @@ gdk_macos_surface_hide (GdkSurface *surface) _gdk_macos_display_remove_frame_callback (GDK_MACOS_DISPLAY (surface->display), self); was_mapped = GDK_SURFACE_IS_MAPPED (GDK_SURFACE (self)); + was_key = [self->window isKeyWindow]; seat = gdk_display_get_default_seat (surface->display); gdk_seat_ungrab (seat); @@ -151,6 +153,17 @@ gdk_macos_surface_hide (GdkSurface *surface) g_clear_object (&self->buffer); + if (was_key) + { + /* Return key input to the parent window if necessary */ + if (surface->parent != NULL && GDK_SURFACE_IS_MAPPED (surface->parent)) + { + GdkMacosWindow *parentWindow = GDK_MACOS_SURFACE (surface->parent)->window; + + [parentWindow showAndMakeKey:YES]; + } + } + if (was_mapped) gdk_surface_freeze_updates (GDK_SURFACE (self)); }