diff --git a/modules/juce_gui_basics/desktop/juce_Desktop.cpp b/modules/juce_gui_basics/desktop/juce_Desktop.cpp index 05a5c67c92..b105bb0b95 100644 --- a/modules/juce_gui_basics/desktop/juce_Desktop.cpp +++ b/modules/juce_gui_basics/desktop/juce_Desktop.cpp @@ -374,4 +374,13 @@ bool Desktop::isHeadless() const noexcept return displays->displays.isEmpty(); } +bool Desktop::supportsBorderlessNonClientResize() const +{ + #if JUCE_WINDOWS || JUCE_MAC + return true; + #else + return false; + #endif +} + } // namespace juce diff --git a/modules/juce_gui_basics/desktop/juce_Desktop.h b/modules/juce_gui_basics/desktop/juce_Desktop.h index 7c57feb2ae..5c3d47e3e0 100644 --- a/modules/juce_gui_basics/desktop/juce_Desktop.h +++ b/modules/juce_gui_basics/desktop/juce_Desktop.h @@ -412,6 +412,12 @@ public: static bool isOSXDarkModeActive() { return Desktop::getInstance().isDarkModeActive(); } #endif + /** Returns true if the desktop environment allows resizing the window by clicking and dragging + just on/outside the window border. + MacOS and Windows 10+ both support this. Linux doesn't seem to. Mobile platforms do not. + */ + bool supportsBorderlessNonClientResize() const; + //============================================================================== /** Returns true on a headless system where there are no connected displays. */ bool isHeadless() const noexcept; diff --git a/modules/juce_gui_basics/windows/juce_ResizableWindow.cpp b/modules/juce_gui_basics/windows/juce_ResizableWindow.cpp index 85bb1e0fc0..b82a8df90d 100644 --- a/modules/juce_gui_basics/windows/juce_ResizableWindow.cpp +++ b/modules/juce_gui_basics/windows/juce_ResizableWindow.cpp @@ -254,6 +254,8 @@ void ResizableWindow::activeWindowStatusChanged() void ResizableWindow::setResizable (const bool shouldBeResizable, const bool useBottomRightCornerResizer) { + resizable = shouldBeResizable; + if (shouldBeResizable) { if (useBottomRightCornerResizer) @@ -271,7 +273,7 @@ void ResizableWindow::setResizable (const bool shouldBeResizable, { resizableCorner.reset(); - if (resizableBorder == nullptr) + if (resizableBorder == nullptr && (! isOnDesktop() || ! Desktop::getInstance().supportsBorderlessNonClientResize())) { resizableBorder.reset (new ResizableBorderComponent (this, constrainer)); Component::addChildComponent (resizableBorder.get()); @@ -293,8 +295,7 @@ void ResizableWindow::setResizable (const bool shouldBeResizable, bool ResizableWindow::isResizable() const noexcept { - return resizableCorner != nullptr - || resizableBorder != nullptr; + return resizable; } void ResizableWindow::setResizeLimits (int newMinimumWidth, diff --git a/modules/juce_gui_basics/windows/juce_ResizableWindow.h b/modules/juce_gui_basics/windows/juce_ResizableWindow.h index 2542590049..d053cf2ab7 100644 --- a/modules/juce_gui_basics/windows/juce_ResizableWindow.h +++ b/modules/juce_gui_basics/windows/juce_ResizableWindow.h @@ -401,7 +401,12 @@ protected: private: //============================================================================== Component::SafePointer contentComponent; - bool ownsContentComponent = false, resizeToFitContent = false, fullscreen = false, canDrag = true, dragStarted = false; + bool ownsContentComponent = false; + bool resizeToFitContent = false; + bool fullscreen = false; + bool canDrag = true; + bool dragStarted = false; + bool resizable = false; ComponentDragger dragger; Rectangle lastNonFullScreenPos; ComponentBoundsConstrainer defaultConstrainer;