Browse Source

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

tags/2021-05-28
jules 11 years ago
parent
commit
a79292179d
5 changed files with 50 additions and 11 deletions
  1. +10
    -0
      modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm
  2. +5
    -0
      modules/juce_gui_basics/windows/juce_ComponentPeer.cpp
  3. +3
    -0
      modules/juce_gui_basics/windows/juce_ComponentPeer.h
  4. +25
    -10
      modules/juce_gui_basics/windows/juce_ResizableWindow.cpp
  5. +7
    -1
      modules/juce_gui_basics/windows/juce_ResizableWindow.h

+ 10
- 0
modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm View File

@@ -378,6 +378,16 @@ public:
return fullScreen; 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 bool contains (Point<int> localPos, bool trueIfInAChildWindow) const override
{ {
NSRect frameRect = [view frame]; NSRect frameRect = [view frame];


+ 5
- 0
modules/juce_gui_basics/windows/juce_ComponentPeer.cpp View File

@@ -79,6 +79,11 @@ void ComponentPeer::updateBounds()
setBounds (ScalingHelpers::scaledScreenPosToUnscaled (component, component.getBoundsInParent()), false); 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, void ComponentPeer::handleMouseEvent (const int touchIndex, const Point<int> positionWithinPeer,
const ModifierKeys newMods, const int64 time) const ModifierKeys newMods, const int64 time)


+ 3
- 0
modules/juce_gui_basics/windows/juce_ComponentPeer.h View File

@@ -176,6 +176,9 @@ public:
/** True if the window is currently full-screen. */ /** True if the window is currently full-screen. */
virtual bool isFullScreen() const = 0; 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. */ /** Sets the size to restore to if fullscreen mode is turned off. */
void setNonFullScreenBounds (const Rectangle<int>& newBounds) noexcept; void setNonFullScreenBounds (const Rectangle<int>& newBounds) noexcept;


+ 25
- 10
modules/juce_gui_basics/windows/juce_ResizableWindow.cpp View File

@@ -177,14 +177,14 @@ BorderSize<int> ResizableWindow::getContentComponentBorder()
void ResizableWindow::moved() void ResizableWindow::moved()
{ {
updateLastPos();
updateLastPosIfShowing();
} }
void ResizableWindow::visibilityChanged() void ResizableWindow::visibilityChanged()
{ {
TopLevelWindow::visibilityChanged(); TopLevelWindow::visibilityChanged();
updateLastPos();
updateLastPosIfShowing();
} }
void ResizableWindow::resized() void ResizableWindow::resized()
@@ -227,7 +227,7 @@ void ResizableWindow::resized()
contentComponent->setBoundsInset (getContentComponentBorder()); contentComponent->setBoundsInset (getContentComponentBorder());
} }
updateLastPos();
updateLastPosIfShowing();
#if JUCE_DEBUG #if JUCE_DEBUG
hasBeenResized = true; hasBeenResized = true;
@@ -424,7 +424,7 @@ void ResizableWindow::setFullScreen (const bool shouldBeFullScreen)
{ {
if (shouldBeFullScreen != isFullScreen()) if (shouldBeFullScreen != isFullScreen())
{ {
updateLastPos();
updateLastPosIfShowing();
fullscreen = shouldBeFullScreen; fullscreen = shouldBeFullScreen;
if (isOnDesktop()) if (isOnDesktop())
@@ -470,7 +470,7 @@ void ResizableWindow::setMinimised (const bool shouldMinimise)
{ {
if (ComponentPeer* const peer = getPeer()) if (ComponentPeer* const peer = getPeer())
{ {
updateLastPos();
updateLastPosIfShowing();
peer->setMinimised (shouldMinimise); peer->setMinimised (shouldMinimise);
} }
else 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(); lastNonFullScreenPos = getBounds();
} }
@@ -495,8 +510,8 @@ void ResizableWindow::parentSizeChanged()
//============================================================================== //==============================================================================
String ResizableWindow::getWindowStateAsString() String ResizableWindow::getWindowStateAsString()
{ {
updateLastPos();
return (isFullScreen() ? "fs " : "") + lastNonFullScreenPos.toString();
updateLastPosIfShowing();
return (isFullScreen() && ! isKioskMode() ? "fs " : "") + lastNonFullScreenPos.toString();
} }
bool ResizableWindow::restoreWindowStateFromString (const String& s) bool ResizableWindow::restoreWindowStateFromString (const String& s)
@@ -548,7 +563,7 @@ bool ResizableWindow::restoreWindowStateFromString (const String& s)
peer->setNonFullScreenBounds (newPos); peer->setNonFullScreenBounds (newPos);
} }
lastNonFullScreenPos = newPos;
updateLastPosIfNotFullScreen();
setFullScreen (fs); setFullScreen (fs);
if (! fs) if (! fs)


+ 7
- 1
modules/juce_gui_basics/windows/juce_ResizableWindow.h View File

@@ -190,6 +190,11 @@ public:
*/ */
void setMinimised (bool shouldMinimise); 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. /** Returns a string which encodes the window's current size and position.
@@ -379,7 +384,8 @@ private:
#endif #endif
void initialise (bool addToDesktop); void initialise (bool addToDesktop);
void updateLastPos();
void updateLastPosIfNotFullScreen();
void updateLastPosIfShowing();
void setContent (Component*, bool takeOwnership, bool resizeToFit); void setContent (Component*, bool takeOwnership, bool resizeToFit);
#if JUCE_CATCH_DEPRECATED_CODE_MISUSE #if JUCE_CATCH_DEPRECATED_CODE_MISUSE


Loading…
Cancel
Save