Skip to content

quartz: Set NSWindowCollectionBehaviorFullScreenNone for GDK_WINDOW_TEMP

Jiří Techet requested to merge jiritechet/gtk:fullscreen_popup_fix into gtk-3-24

GDK_WINDOW_TEMP which corresponds to GTK_WINDOW_POPUP windows should never be allowed to be automatically full screened by macOS (which happens when the main window of the app is also fullscreened). Using NSWindowCollectionBehaviorFullScreenNone should prevent that.

I'm not really a GTK-internals expert so someone with more knowledge should check if this patch doesn't have any side-effects and if there's not a better way to do this (@jralls does it look good to you?).

From what I have seen, inside gtkwindow.c, GTK_WINDOW_POPUP is always mapped to GDK_WINDOW_TEMP and inside gdkwindow-quartz.c the setCollectionBehavior method of NSWindow is only used in _gdk_quartz_window_set_collection_behavior() which in turn is only called in gdk_quartz_window_set_type_hint() to set the fullscreen behavior based on window hints.

_gdk_quartz_window_set_collection_behavior() only sets and unsets the corresponding bits so NSWindowCollectionBehaviorFullScreenNone should be preserved when added during the window creation (I don't know what macOS does when both NSWindowCollectionBehaviorFullScreenNone and NSWindowCollectionBehaviorFullScreenPrimary are set but I'd assume it prefers the NSWindowCollectionBehaviorFullScreenNone flag). So in my opinion this patch should be safe.

Note that if you test this with the sample I gave in #5716 (closed), you should also add gtk_window_set_transient_for() for the popup otherwise the popup appears on the main workspace instead of the workspace of the maximized window.

Fixes #5716 (closed).

Merge request reports