mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
NSViewComponentPeer: Only allow full screen mode for resizable windows with maximise buttons
Effects of this change for windows with native titlebars: - Resizable windows without maximise buttons will now only allow the 'zoom' behaviour from the rightmost titlebar button (i.e. this button will not allow entering full-screen mode) - Non-resizable windows will grey-out the rightmost titlebar button, whether or not the maximise button is enabled
This commit is contained in:
parent
05676c862a
commit
8a2bde9fec
1 changed files with 41 additions and 17 deletions
|
|
@ -197,8 +197,7 @@ public:
|
|||
[window setExcludedFromWindowsMenu: (windowStyleFlags & windowIsTemporary) != 0];
|
||||
[window setIgnoresMouseEvents: (windowStyleFlags & windowIgnoresMouseClicks) != 0];
|
||||
|
||||
if ((windowStyleFlags & windowHasMaximiseButton) == windowHasMaximiseButton)
|
||||
[window setCollectionBehavior: NSWindowCollectionBehaviorFullScreenPrimary];
|
||||
setCollectionBehaviour (false);
|
||||
|
||||
[window setRestorable: NO];
|
||||
|
||||
|
|
@ -407,22 +406,42 @@ 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)
|
||||
{
|
||||
if (isMinimised())
|
||||
setMinimised (false);
|
||||
if (isSharedWindow)
|
||||
return;
|
||||
|
||||
if (hasNativeTitleBar())
|
||||
{
|
||||
if (shouldBeFullScreen != isFullScreen())
|
||||
[window toggleFullScreen: nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
[window zoom: nil];
|
||||
}
|
||||
setCollectionBehaviour (shouldBeFullScreen);
|
||||
|
||||
if (isMinimised())
|
||||
setMinimised (false);
|
||||
|
||||
if (hasNativeTitleBar())
|
||||
{
|
||||
if (shouldBeFullScreen != isFullScreen())
|
||||
[window toggleFullScreen: nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
[window zoom: nil];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1549,6 +1568,7 @@ public:
|
|||
}
|
||||
|
||||
[NSApp setPresentationOptions: NSApplicationPresentationDefault];
|
||||
setCollectionBehaviour (isFullScreen());
|
||||
}
|
||||
|
||||
void setHasChangedSinceSaved (bool b) override
|
||||
|
|
@ -2323,8 +2343,12 @@ private:
|
|||
return makeNSRect (Rectangle<int> (10000, 10000));
|
||||
}
|
||||
|
||||
static BOOL windowShouldZoomToFrame (id, SEL, NSWindow* window, NSRect frame)
|
||||
static BOOL windowShouldZoomToFrame (id self, SEL, NSWindow* window, NSRect frame)
|
||||
{
|
||||
if (auto* owner = getOwner (self))
|
||||
if (owner->hasNativeTitleBar() && (owner->getStyleFlags() & ComponentPeer::windowIsResizable) == 0)
|
||||
return NO;
|
||||
|
||||
return convertToRectFloat ([window frame]).withZeroOrigin() != convertToRectFloat (frame).withZeroOrigin();
|
||||
}
|
||||
|
||||
|
|
@ -2545,7 +2569,7 @@ void Desktop::setKioskComponent (Component* kioskComp, bool shouldBeEnabled, boo
|
|||
else if (! shouldBeEnabled)
|
||||
[NSApp setPresentationOptions: NSApplicationPresentationDefault];
|
||||
|
||||
[peer->window toggleFullScreen: nil];
|
||||
peer->setFullScreen (true);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue