From 32928d231cc46b2133c2dfe72d5cb3e9ccfd5ac7 Mon Sep 17 00:00:00 2001 From: topemalheiro Date: Thu, 12 Nov 2026 11:28:29 +0000 Subject: [PATCH] Wayland: Add isWaylandWindowMaximisedOrTiled() The toplevel already knows whether the compositor has maximised or tiled the window (maximisedOrTiled in its configure info), but only the strictly maximised state was exposed. An application that draws its own shadow around the window needs to know about tiling too: a half-tiled window is placed edge to edge by the compositor and the shadow inset has to go. Co-Authored-By: Claude Sonnet 5.5 --- .../native/juce_WaylandWindowState_linux.h | 9 +++++++++ .../native/juce_Windowing_wayland_linux.cpp | 16 ++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/modules/juce_gui_basics/native/juce_WaylandWindowState_linux.h b/modules/juce_gui_basics/native/juce_WaylandWindowState_linux.h index 370ef2c6a929..46d9a4ce1d82 100644 --- a/modules/juce_gui_basics/native/juce_WaylandWindowState_linux.h +++ b/modules/juce_gui_basics/native/juce_WaylandWindowState_linux.h @@ -54,4 +54,13 @@ JUCE_API bool setWaylandWindowMaximised (ComponentPeer&, bool shouldBeMaximised) */ JUCE_API bool isWaylandWindowMaximised (const ComponentPeer&); +/** Returns true if the compositor has configured a top-level Wayland window as maximised or + as tiled on at least one edge (half-tiled, snapped to a corner...). + + Like isWaylandWindowMaximised() it changes in the same configure as the window's size. It lets + an application that draws its own shadow around the window know that the compositor now + manages the window's edges, so the shadow should be dropped. +*/ +JUCE_API bool isWaylandWindowMaximisedOrTiled (const ComponentPeer&); + } // namespace juce diff --git a/modules/juce_gui_basics/native/juce_Windowing_wayland_linux.cpp b/modules/juce_gui_basics/native/juce_Windowing_wayland_linux.cpp index a148d15dfd46..a98c40cc2edb 100644 --- a/modules/juce_gui_basics/native/juce_Windowing_wayland_linux.cpp +++ b/modules/juce_gui_basics/native/juce_Windowing_wayland_linux.cpp @@ -587,6 +587,11 @@ class WaylandComponentPeer final : public ComponentPeer, return maximised; } + bool isMaximisedOrTiled() const + { + return maximisedOrTiled; + } + void startHostManagedResize (Point, ResizableBorderComponent::Zone zone) override { if (updateToplevelSizeConstraints()) @@ -1379,6 +1384,7 @@ class WaylandComponentPeer final : public ComponentPeer, // The compositor discards all toplevel state on unmap. fullScreenState.toplevelDestroyed(); maximised = false; + maximisedOrTiled = false; wantsMinimised = false; dialogOwner = nullptr; } @@ -1892,6 +1898,7 @@ class WaylandComponentPeer final : public ComponentPeer, fullScreenState.configureReceived (info.fullScreen); maximised = info.maximised; + maximisedOrTiled = info.maximisedOrTiled; configured = true; // xdg-shell has no unminimise event, so an activated configure means the compositor showed us again. @@ -2450,6 +2457,7 @@ class WaylandComponentPeer final : public ComponentPeer, // As last configured, so it changes together with the size that goes with it. bool maximised = false; + bool maximisedOrTiled = false; std::optional configureScaleUpdate; WaylandResizeAxesTracker resizeAxesTracker; WaylandSurfaceScale surfaceScale; @@ -2580,6 +2588,14 @@ bool isWaylandWindowMaximised (const ComponentPeer& peer) return false; } +bool isWaylandWindowMaximisedOrTiled (const ComponentPeer& peer) +{ + if (auto* waylandPeer = dynamic_cast (&peer)) + return waylandPeer->isMaximisedOrTiled(); + + return false; +} + //============================================================================== class WaylandMouseCursor final {