/* A GSource to select a new main/key window */
guint select_key_in_idle;
+
+ /* Note if we have a key window that is not a GdkMacosWindow
+ * such as a NSPanel used for native dialogs.
+ */
+ guint key_window_is_foregin : 1;
};
struct _GdkMacosDisplayClass
self->select_key_in_idle = 0;
+ /* Don't steal focus from NSPanel, etc */
+ if (self->key_window_is_foregin)
+ return G_SOURCE_REMOVE;
+
if (self->keyboard_surface == NULL)
{
const GList *surfaces = _gdk_macos_display_get_surfaces (self);
NSArray *array = [NSApp orderedWindows];
GQueue sorted = G_QUEUE_INIT;
+ self->key_window_is_foregin = FALSE;
+
for (id obj in array)
{
NSWindow *nswindow = (NSWindow *)obj;
GdkMacosSurface *surface;
+ if ([nswindow isKeyWindow])
+ self->key_window_is_foregin = !GDK_IS_MACOS_WINDOW (nswindow);
+
if (!GDK_IS_MACOS_WINDOW (nswindow))
continue;