diff --git a/build/linux/platform_specific_code/juce_linux_Windowing.cpp b/build/linux/platform_specific_code/juce_linux_Windowing.cpp index 061c7f5840..e1281d91a4 100644 --- a/build/linux/platform_specific_code/juce_linux_Windowing.cpp +++ b/build/linux/platform_specific_code/juce_linux_Windowing.cpp @@ -867,14 +867,14 @@ public: return minimised; } - void setFullScreen (bool shouldBeFullScreen) + void setFullScreen (const bool shouldBeFullScreen) { + Rectangle r (lastNonFullscreenBounds); // (get a copy of this before de-minimising) + setMinimised (false); if (fullScreen != shouldBeFullScreen) { - Rectangle r (lastNonFullscreenBounds); - if (shouldBeFullScreen) r = Desktop::getInstance().getMainMonitorArea(); diff --git a/build/macosx/platform_specific_code/juce_mac_Windowing.cpp b/build/macosx/platform_specific_code/juce_mac_Windowing.cpp index f2eea94262..98d1092cdb 100644 --- a/build/macosx/platform_specific_code/juce_mac_Windowing.cpp +++ b/build/macosx/platform_specific_code/juce_mac_Windowing.cpp @@ -571,12 +571,12 @@ public: { if (! isSharedWindow) { + Rectangle r (lastNonFullscreenBounds); + setMinimised (false); if (fullScreen != shouldBeFullScreen) { - Rectangle r (lastNonFullscreenBounds); - if (shouldBeFullScreen) r = Desktop::getInstance().getMainMonitorArea(); diff --git a/build/win32/platform_specific_code/juce_win32_Windowing.cpp b/build/win32/platform_specific_code/juce_win32_Windowing.cpp index b5969a3e7d..017d923db6 100644 --- a/build/win32/platform_specific_code/juce_win32_Windowing.cpp +++ b/build/win32/platform_specific_code/juce_win32_Windowing.cpp @@ -731,15 +731,17 @@ public: if (! fullScreen) { + const Rectangle boundsCopy (lastNonFullscreenBounds); + if (hasTitleBar()) ShowWindow (hwnd, SW_SHOWNORMAL); - if (! lastNonFullscreenBounds.isEmpty()) + if (! boundsCopy.isEmpty()) { - setBounds (lastNonFullscreenBounds.getX(), - lastNonFullscreenBounds.getY(), - lastNonFullscreenBounds.getWidth(), - lastNonFullscreenBounds.getHeight(), + setBounds (boundsCopy.getX(), + boundsCopy.getY(), + boundsCopy.getWidth(), + boundsCopy.getHeight(), false); } } diff --git a/src/juce_appframework/gui/components/juce_Component.cpp b/src/juce_appframework/gui/components/juce_Component.cpp index a37255331a..6c92533406 100644 --- a/src/juce_appframework/gui/components/juce_Component.cpp +++ b/src/juce_appframework/gui/components/juce_Component.cpp @@ -465,12 +465,14 @@ void Component::addToDesktop (int styleWanted, void* nativeWindowToAttachTo) bool wasFullscreen = false; bool wasMinimised = false; ComponentBoundsConstrainer* currentConstainer = 0; + Rectangle oldNonFullScreenBounds; if (peer != 0) { wasFullscreen = peer->isFullScreen(); wasMinimised = peer->isMinimised(); currentConstainer = peer->getConstrainer(); + oldNonFullScreenBounds = peer->getNonFullScreenBounds(); removeFromDesktop(); } @@ -492,7 +494,10 @@ void Component::addToDesktop (int styleWanted, void* nativeWindowToAttachTo) peer->setVisible (isVisible()); if (wasFullscreen) + { peer->setFullScreen (true); + peer->setNonFullScreenBounds (oldNonFullScreenBounds); + } if (wasMinimised) peer->setMinimised (true); diff --git a/src/juce_appframework/gui/components/windows/juce_ComponentPeer.cpp b/src/juce_appframework/gui/components/windows/juce_ComponentPeer.cpp index fe19cfd66a..b76349c7a0 100644 --- a/src/juce_appframework/gui/components/windows/juce_ComponentPeer.cpp +++ b/src/juce_appframework/gui/components/windows/juce_ComponentPeer.cpp @@ -643,6 +643,16 @@ void ComponentPeer::handleScreenSizeChange() handleMovedOrResized(); } +void ComponentPeer::setNonFullScreenBounds (const Rectangle& newBounds) throw() +{ + lastNonFullscreenBounds = newBounds; +} + +const Rectangle& ComponentPeer::getNonFullScreenBounds() const throw() +{ + return lastNonFullscreenBounds; +} + //============================================================================== void ComponentPeer::handleFilesDropped (int x, int y, const StringArray& files) { diff --git a/src/juce_appframework/gui/components/windows/juce_ComponentPeer.h b/src/juce_appframework/gui/components/windows/juce_ComponentPeer.h index 98263ee1d0..9247a1ac2d 100644 --- a/src/juce_appframework/gui/components/windows/juce_ComponentPeer.h +++ b/src/juce_appframework/gui/components/windows/juce_ComponentPeer.h @@ -174,6 +174,12 @@ public: /** True if the window is currently full-screen. */ virtual bool isFullScreen() const = 0; + /** Sets the size to restore to if fullscreen mode is turned off. */ + void setNonFullScreenBounds (const Rectangle& newBounds) throw(); + + /** Returns the size to restore to if fullscreen mode is turned off. */ + const Rectangle& getNonFullScreenBounds() const throw(); + /** Attempts to change the icon associated with this window. */ virtual void setIcon (const Image& newIcon) = 0; diff --git a/src/juce_appframework/gui/components/windows/juce_ResizableWindow.cpp b/src/juce_appframework/gui/components/windows/juce_ResizableWindow.cpp index 16a1c514a3..b7a8bd1bf8 100644 --- a/src/juce_appframework/gui/components/windows/juce_ResizableWindow.cpp +++ b/src/juce_appframework/gui/components/windows/juce_ResizableWindow.cpp @@ -477,13 +477,22 @@ bool ResizableWindow::restoreWindowStateFromString (const String& s) return false; lastNonFullScreenPos = r; + + if (isOnDesktop()) + { + ComponentPeer* const peer = getPeer(); + + if (peer != 0) + peer->setNonFullScreenBounds (r); + } + setFullScreen (fs); if (! fs) - setBoundsConstrained (lastNonFullScreenPos.getX(), - lastNonFullScreenPos.getY(), - lastNonFullScreenPos.getWidth(), - lastNonFullScreenPos.getHeight()); + setBoundsConstrained (r.getX(), + r.getY(), + r.getWidth(), + r.getHeight()); return true; }