1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Better handling of ResizableWindow screen bounds handling when in kiosk mode.

This commit is contained in:
jules 2014-01-09 17:44:46 +00:00
parent b4bd383a46
commit a79292179d
5 changed files with 50 additions and 11 deletions

View file

@ -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<int> localPos, bool trueIfInAChildWindow) const override
{
NSRect frameRect = [view frame];

View file

@ -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<int> positionWithinPeer,
const ModifierKeys newMods, const int64 time)

View file

@ -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<int>& newBounds) noexcept;

View file

@ -177,14 +177,14 @@ BorderSize<int> 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)

View file

@ -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