From f013c74611219627f3f2a4ad3aa76789db18bb07 Mon Sep 17 00:00:00 2001 From: topemalheiro Date: Thu, 12 Nov 2026 11:34:26 +0000 Subject: [PATCH 1/3] Update JUCE for isWaylandWindowMaximisedOrTiled() Points at the JUCE branch pr/linux-maximize (one commit on juce-master). Needs to be replaced by the merged JUCE commit. Co-Authored-By: Claude Sonnet 5.5 --- Libraries/JUCE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From f3e89ae4298ab94cda6fd9b0694a99bccaef19ca Mon Sep 17 00:00:00 2001 From: topemalheiro Date: Thu, 12 Nov 2026 11:34:18 +0000 Subject: [PATCH 2/3] Linux: remove the window shadow inset when the window is tiled on Wayland We draw our own shadow around the window, which is removed when the window is maximised because the window manager then places it edge to edge. A tiled window (half screen, quarter screen...) is placed edge to edge as well, but only maximised was checked, so a tiled window kept its 18 px inset, the rounded corners and the shadow. This uses isWaylandWindowMaximisedOrTiled(), which needs the JUCE change that exposes it. On X11 only the maximised state is visible to us, so nothing changes there. Co-Authored-By: Claude Sonnet 5.5 --- Source/PluginEditor.cpp | 2 +- Source/Standalone/PlugDataWindow.h | 23 ++++++++++++++++++++--- Source/Utility/OSUtils.cpp | 9 +++++++++ Source/Utility/OSUtils.h | 1 + 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index 941c87766..75e3db593 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -2016,7 +2016,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); From c825f35b14bc2c547892e1ac11710e430ff88db3 Mon Sep 17 00:00:00 2001 From: topemalheiro Date: Thu, 12 Nov 2026 11:34:18 +0000 Subject: [PATCH 3/3] Linux: don't start a window drag from the second click of a title bar double-click Double-clicking the title bar maximises or restores the window, and the same click then also started dragging it. On Wayland the compositor began moving the window while it was being maximised, so it ended up maximised but displaced, and restored to the wrong place. Co-Authored-By: Claude Sonnet 5.5 --- Source/PluginEditor.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index 75e3db593..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 }