From bfd35223eaf01347e591510a0ae9d4416899b4c6 Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Fri, 16 May 2025 00:11:09 -0700 Subject: [PATCH] wayland/layershell: ensure exclusive zone is updated on zone/mode chg --- src/wayland/wlr_layershell/wlr_layershell.cpp | 28 +++++++++---------- src/wayland/wlr_layershell/wlr_layershell.hpp | 3 +- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/wayland/wlr_layershell/wlr_layershell.cpp b/src/wayland/wlr_layershell/wlr_layershell.cpp index 648e64b..2c80c02 100644 --- a/src/wayland/wlr_layershell/wlr_layershell.cpp +++ b/src/wayland/wlr_layershell/wlr_layershell.cpp @@ -14,7 +14,20 @@ namespace qs::wayland::layershell { -WlrLayershell::WlrLayershell(QObject* parent): ProxyWindowBase(parent) {} +WlrLayershell::WlrLayershell(QObject* parent): ProxyWindowBase(parent) { + this->bcExclusiveZone.setBinding([this]() -> qint32 { + switch (this->bExclusionMode.value()) { + case ExclusionMode::Ignore: return -1; + case ExclusionMode::Normal: return this->bExclusiveZone; + case ExclusionMode::Auto: + const auto anchors = this->bAnchors.value(); + + if (anchors.horizontalConstraint()) return this->height(); + else if (anchors.verticalConstraint()) return this->width(); + else return 0; + } + }); +} ProxiedWindow* WlrLayershell::retrieveWindow(QObject* oldInstance) { auto* old = qobject_cast(oldInstance); @@ -112,19 +125,6 @@ LayerSurfaceState WlrLayershell::computeState() const { }; } -qint32 WlrLayershell::computeExclusiveZone() const { - switch (this->bExclusionMode.value()) { - case ExclusionMode::Ignore: return -1; - case ExclusionMode::Normal: return this->bExclusiveZone; - case ExclusionMode::Auto: - const auto anchors = this->bAnchors.value(); - - if (anchors.horizontalConstraint()) return this->height(); - else if (anchors.verticalConstraint()) return this->width(); - else return 0; - } -} - void WlrLayershell::updateAutoExclusion() { this->bcExclusiveZone.notify(); } WlrLayershell* WlrLayershell::qmlAttachedProperties(QObject* object) { diff --git a/src/wayland/wlr_layershell/wlr_layershell.hpp b/src/wayland/wlr_layershell/wlr_layershell.hpp index 98e8d4b..56dd060 100644 --- a/src/wayland/wlr_layershell/wlr_layershell.hpp +++ b/src/wayland/wlr_layershell/wlr_layershell.hpp @@ -178,7 +178,6 @@ private slots: private: [[nodiscard]] LayerSurfaceState computeState() const; - [[nodiscard]] qint32 computeExclusiveZone() const; void onStateChanged(); @@ -193,7 +192,7 @@ private: Q_OBJECT_BINDABLE_PROPERTY(WlrLayershell, qint32, bExclusiveZone, &WlrLayershell::exclusiveZoneChanged); Q_OBJECT_BINDABLE_PROPERTY(WlrLayershell, WlrKeyboardFocus::Enum, bKeyboardFocus, &WlrLayershell::keyboardFocusChanged); Q_OBJECT_BINDABLE_PROPERTY_WITH_ARGS(WlrLayershell, ExclusionMode::Enum, bExclusionMode, ExclusionMode::Auto, &WlrLayershell::exclusionModeChanged); - Q_OBJECT_COMPUTED_PROPERTY(WlrLayershell, qint32, bcExclusiveZone, &WlrLayershell::computeExclusiveZone); + Q_OBJECT_BINDABLE_PROPERTY(WlrLayershell, qint32, bcExclusiveZone); QS_BINDING_SUBSCRIBE_METHOD(WlrLayershell, bLayer, onStateChanged, onValueChanged); QS_BINDING_SUBSCRIBE_METHOD(WlrLayershell, bAnchors, onStateChanged, onValueChanged);