From 9bd52d59af4f1a1c579fb009fbb1ae2b389f8aea Mon Sep 17 00:00:00 2001 From: reuk Date: Mon, 21 Feb 2022 12:34:11 +0000 Subject: [PATCH] NSViewComponentPeer: Avoid making temporary windows (dropdowns, callouts) full-screen when in full-screen mode eabcfbad26c658f628796e4433a76365df3cdeb2 incorrectly set the collection behaviour NSWindowCollectionBehaviorFullScreenPrimary on all top-level components, which would cause popup menus and callouts to appear in their own space when launched from an app running in full-screen mode. --- .../native/juce_mac_NSViewComponentPeer.mm | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm index a368730ca5..d8f4ea4ba8 100644 --- a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm +++ b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm @@ -198,7 +198,7 @@ public: [window setExcludedFromWindowsMenu: (windowStyleFlags & windowIsTemporary) != 0]; [window setIgnoresMouseEvents: (windowStyleFlags & windowIgnoresMouseClicks) != 0]; - [window setCollectionBehavior: NSWindowCollectionBehaviorFullScreenPrimary]; + setCollectionBehaviour (false); [window setRestorable: NO]; @@ -407,11 +407,32 @@ public: return [window isMiniaturized]; } + NSWindowCollectionBehavior getCollectionBehavior (bool forceFullScreen) const + { + if (forceFullScreen) + return NSWindowCollectionBehaviorFullScreenPrimary; + + // Some SDK versions don't define NSWindowCollectionBehaviorFullScreenNone + constexpr auto fullScreenNone = (NSUInteger) (1 << 9); + + return (getStyleFlags() & (windowHasMaximiseButton | windowIsResizable)) == (windowHasMaximiseButton | windowIsResizable) + ? NSWindowCollectionBehaviorFullScreenPrimary + : fullScreenNone; + } + + void setCollectionBehaviour (bool forceFullScreen) const + { + [window setCollectionBehavior: getCollectionBehavior (forceFullScreen)]; + } + void setFullScreen (bool shouldBeFullScreen) override { if (isSharedWindow) return; + if (shouldBeFullScreen) + setCollectionBehaviour (true); + if (isMinimised()) setMinimised (false); @@ -1573,6 +1594,7 @@ public: } [NSApp setPresentationOptions: NSApplicationPresentationDefault]; + setCollectionBehaviour (isFullScreen()); } void setHasChangedSinceSaved (bool b) override