diff --git a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm index 54bce81756..94eed9f4da 100644 --- a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm +++ b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm @@ -378,6 +378,16 @@ public: return fullScreen; } + bool isKioskMode() const override + { + #if defined (MAC_OS_X_VERSION_10_7) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 + if (hasNativeTitleBar() && ([window styleMask] & NSFullScreenWindowMask) != 0) + return true; + #endif + + return ComponentPeer::isKioskMode(); + } + bool contains (Point localPos, bool trueIfInAChildWindow) const override { NSRect frameRect = [view frame]; diff --git a/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp b/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp index c6e1930086..976c5a4282 100644 --- a/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp +++ b/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp @@ -79,6 +79,11 @@ void ComponentPeer::updateBounds() setBounds (ScalingHelpers::scaledScreenPosToUnscaled (component, component.getBoundsInParent()), false); } +bool ComponentPeer::isKioskMode() const +{ + return Desktop::getInstance().getKioskModeComponent() == &component; +} + //============================================================================== void ComponentPeer::handleMouseEvent (const int touchIndex, const Point positionWithinPeer, const ModifierKeys newMods, const int64 time) diff --git a/modules/juce_gui_basics/windows/juce_ComponentPeer.h b/modules/juce_gui_basics/windows/juce_ComponentPeer.h index 2dc2d3f5c1..600425c6c9 100644 --- a/modules/juce_gui_basics/windows/juce_ComponentPeer.h +++ b/modules/juce_gui_basics/windows/juce_ComponentPeer.h @@ -176,6 +176,9 @@ public: /** True if the window is currently full-screen. */ virtual bool isFullScreen() const = 0; + /** True if the window is in kiosk-mode. */ + virtual bool isKioskMode() const; + /** Sets the size to restore to if fullscreen mode is turned off. */ void setNonFullScreenBounds (const Rectangle& newBounds) noexcept; diff --git a/modules/juce_gui_basics/windows/juce_ResizableWindow.cpp b/modules/juce_gui_basics/windows/juce_ResizableWindow.cpp index 300373be1f..28c34e6217 100644 --- a/modules/juce_gui_basics/windows/juce_ResizableWindow.cpp +++ b/modules/juce_gui_basics/windows/juce_ResizableWindow.cpp @@ -177,14 +177,14 @@ BorderSize ResizableWindow::getContentComponentBorder() void ResizableWindow::moved() { - updateLastPos(); + updateLastPosIfShowing(); } void ResizableWindow::visibilityChanged() { TopLevelWindow::visibilityChanged(); - updateLastPos(); + updateLastPosIfShowing(); } void ResizableWindow::resized() @@ -227,7 +227,7 @@ void ResizableWindow::resized() contentComponent->setBoundsInset (getContentComponentBorder()); } - updateLastPos(); + updateLastPosIfShowing(); #if JUCE_DEBUG hasBeenResized = true; @@ -424,7 +424,7 @@ void ResizableWindow::setFullScreen (const bool shouldBeFullScreen) { if (shouldBeFullScreen != isFullScreen()) { - updateLastPos(); + updateLastPosIfShowing(); fullscreen = shouldBeFullScreen; if (isOnDesktop()) @@ -470,7 +470,7 @@ void ResizableWindow::setMinimised (const bool shouldMinimise) { if (ComponentPeer* const peer = getPeer()) { - updateLastPos(); + updateLastPosIfShowing(); peer->setMinimised (shouldMinimise); } else @@ -480,9 +480,24 @@ void ResizableWindow::setMinimised (const bool shouldMinimise) } } -void ResizableWindow::updateLastPos() +bool ResizableWindow::isKioskMode() const { - if (isShowing() && ! (isFullScreen() || isMinimised())) + if (isOnDesktop()) + if (ComponentPeer* peer = getPeer()) + return peer->isKioskMode(); + + return Desktop::getInstance().getKioskModeComponent() == this; +} + +void ResizableWindow::updateLastPosIfShowing() +{ + if (isShowing()) + updateLastPosIfNotFullScreen(); +} + +void ResizableWindow::updateLastPosIfNotFullScreen() +{ + if (! (isFullScreen() || isMinimised() || isKioskMode())) lastNonFullScreenPos = getBounds(); } @@ -495,8 +510,8 @@ void ResizableWindow::parentSizeChanged() //============================================================================== String ResizableWindow::getWindowStateAsString() { - updateLastPos(); - return (isFullScreen() ? "fs " : "") + lastNonFullScreenPos.toString(); + updateLastPosIfShowing(); + return (isFullScreen() && ! isKioskMode() ? "fs " : "") + lastNonFullScreenPos.toString(); } bool ResizableWindow::restoreWindowStateFromString (const String& s) @@ -548,7 +563,7 @@ bool ResizableWindow::restoreWindowStateFromString (const String& s) peer->setNonFullScreenBounds (newPos); } - lastNonFullScreenPos = newPos; + updateLastPosIfNotFullScreen(); setFullScreen (fs); if (! fs) diff --git a/modules/juce_gui_basics/windows/juce_ResizableWindow.h b/modules/juce_gui_basics/windows/juce_ResizableWindow.h index 7a7ffd74a0..dd9f806ed2 100644 --- a/modules/juce_gui_basics/windows/juce_ResizableWindow.h +++ b/modules/juce_gui_basics/windows/juce_ResizableWindow.h @@ -190,6 +190,11 @@ public: */ void setMinimised (bool shouldMinimise); + /** Returns true if the window has been placed in kiosk-mode. + @see Desktop::setKioskComponent + */ + bool isKioskMode() const; + //============================================================================== /** Returns a string which encodes the window's current size and position. @@ -379,7 +384,8 @@ private: #endif void initialise (bool addToDesktop); - void updateLastPos(); + void updateLastPosIfNotFullScreen(); + void updateLastPosIfShowing(); void setContent (Component*, bool takeOwnership, bool resizeToFit); #if JUCE_CATCH_DEPRECATED_CODE_MISUSE