diff --git a/Libraries/JUCE b/Libraries/JUCE index 60c451d55..32928d231 160000 --- a/Libraries/JUCE +++ b/Libraries/JUCE @@ -1 +1 @@ -Subproject commit 60c451d55b958f8663f25faed6d8c92edc0844af +Subproject commit 32928d231cc46b2133c2dfe72d5cb3e9ccfd5ac7 diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index 941c87766..7ded97b1d 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -888,6 +888,11 @@ void PluginEditor::mouseDown(MouseEvent const& e) #else findParentComponentOfClass()->maximiseButtonPressed(); +# if JUCE_LINUX || JUCE_BSD + // The second click must not also start dragging the window: on Wayland the compositor would + // start moving the window while it is being maximised or restored, and it ends up displaced + return; +# endif #endif } @@ -2016,7 +2021,7 @@ bool PluginEditor::wantsRoundedCorners() const // Since this is called in a paint routine, use reinterpret_cast instead of dynamic_cast for efficiency // For the standalone, the top-level component should always be DocumentWindow derived! if (auto const* window = reinterpret_cast(getTopLevelComponent())) { - return !window->useNativeTitlebar() && !window->isMaximised() && ProjectInfo::canUseSemiTransparentWindows(); + return !window->useNativeTitlebar() && !window->isMaximisedOrTiled() && ProjectInfo::canUseSemiTransparentWindows(); } return true; } diff --git a/Source/Standalone/PlugDataWindow.h b/Source/Standalone/PlugDataWindow.h index 8597573e4..e9c864a53 100644 --- a/Source/Standalone/PlugDataWindow.h +++ b/Source/Standalone/PlugDataWindow.h @@ -543,6 +543,23 @@ class PlugDataWindow final : public DocumentWindow #endif } + // True if the window manager places the window edge to edge: maximised, but on Wayland also tiled + // (half-screen, quarter-screen...). We draw our own window shadow, which has to go in that case. + bool isMaximisedOrTiled() const + { +#if JUCE_LINUX || JUCE_BSD + if (hasPendingLinuxMaximisedState) + return pendingLinuxMaximisedState; + + if (auto* peer = getPeer()) + return OSUtils::isLinuxWindowMaximisedOrTiled(peer); + + return isFullScreen(); +#else + return isMaximised(); +#endif + } + static bool useNativeTitlebar() { return SettingsFile::getInstance()->getProperty("native_window"); @@ -583,7 +600,7 @@ class PlugDataWindow final : public DocumentWindow #if JUCE_LINUX || JUCE_BSD void paint(Graphics& g) override { - if (drawWindowShadow && !useNativeTitlebar() && !isMaximised()) { + if (drawWindowShadow && !useNativeTitlebar() && !isMaximisedOrTiled()) { StackShadow::drawShadowForRect(g, getLocalBounds().reduced(18), Corners::windowCornerRadius, StackShadow::Window, isActiveWindow() ? 1.0f : 0.5f); } } @@ -600,7 +617,7 @@ class PlugDataWindow final : public DocumentWindow g.drawRect(0, 0, getWidth(), getHeight()); } # else - if (drawWindowShadow && !useNativeTitlebar() && !isMaximised()) { + if (drawWindowShadow && !useNativeTitlebar() && !isMaximisedOrTiled()) { g.setColour(colours.outlineColour.withAlpha(isActiveWindow() ? 1.0f : 0.5f)); g.drawRoundedRectangle(18, 18, getWidth() - 36, getHeight() - 36, Corners::windowCornerRadius, 1.0f); } else if (drawWindowShadow && !useNativeTitlebar()) { @@ -738,7 +755,7 @@ class PlugDataWindow final : public DocumentWindow #if JUCE_LINUX || JUCE_BSD if (drawWindowShadow) { - return owner.isMaximised() ? 0 : 18; + return owner.isMaximisedOrTiled() ? 0 : 18; } else { return 0; } diff --git a/Source/Utility/OSUtils.cpp b/Source/Utility/OSUtils.cpp index 17d9bc1ae..e26129880 100644 --- a/Source/Utility/OSUtils.cpp +++ b/Source/Utility/OSUtils.cpp @@ -336,6 +336,15 @@ bool OSUtils::isLinuxWindowMaximised(ComponentPeer* peer) return (state & WINDOW_STATE_MAXIMIZED) != 0; } +bool OSUtils::isLinuxWindowMaximisedOrTiled(ComponentPeer* peer) +{ + // On X11 the window manager doesn't tell us about tiling, we only see the maximised state + if (isWaylandWindow(peer)) + return juce::isWaylandWindowMaximisedOrTiled(*peer); + + return isLinuxWindowMaximised(peer); +} + void OSUtils::maximiseLinuxWindow(ComponentPeer* peer, bool shouldBeMaximised) { // Not peer->setFullScreen(): on Wayland that requests a fullscreen window rather than a maximised one diff --git a/Source/Utility/OSUtils.h b/Source/Utility/OSUtils.h index fec3cbe3a..1974cabea 100644 --- a/Source/Utility/OSUtils.h +++ b/Source/Utility/OSUtils.h @@ -39,6 +39,7 @@ struct OSUtils { static bool isWaylandWindow(juce::ComponentPeer* peer); static void maximiseLinuxWindow(juce::ComponentPeer* peer, bool shouldBeMaximised); static bool isLinuxWindowMaximised(juce::ComponentPeer* peer); + static bool isLinuxWindowMaximisedOrTiled(juce::ComponentPeer* peer); static void updateLinuxWindowConstraints(juce::ComponentPeer* peer); #elif JUCE_MAC static void setWindowMovable(juce::ComponentPeer* peer, bool canMove);