diff --git a/src/wayland/wlr_layershell/wlr_layershell.cpp b/src/wayland/wlr_layershell/wlr_layershell.cpp index 4e61530b..0960ca58 100644 --- a/src/wayland/wlr_layershell/wlr_layershell.cpp +++ b/src/wayland/wlr_layershell/wlr_layershell.cpp @@ -1,6 +1,7 @@ #include "wlr_layershell.hpp" #include +#include #include #include #include @@ -20,13 +21,15 @@ WlrLayershell::WlrLayershell(QObject* parent): ProxyWindowBase(parent) { case ExclusionMode::Ignore: return -1; case ExclusionMode::Normal: return this->bExclusiveZone; case ExclusionMode::Auto: - const auto anchors = this->bAnchors.value(); + const auto edge = this->bcExclusionEdge.value(); - if (anchors.horizontalConstraint()) return this->bImplicitHeight; - else if (anchors.verticalConstraint()) return this->bImplicitWidth; + if (edge == Qt::TopEdge || edge == Qt::BottomEdge) return this->bImplicitHeight; + else if (edge == Qt::LeftEdge || edge == Qt::RightEdge) return this->bImplicitWidth; else return 0; } }); + + this->bcExclusionEdge.setBinding([this] { return this->bAnchors.value().exclusionEdge(); }); } ProxiedWindow* WlrLayershell::retrieveWindow(QObject* oldInstance) { diff --git a/src/wayland/wlr_layershell/wlr_layershell.hpp b/src/wayland/wlr_layershell/wlr_layershell.hpp index 739f5ff2..457a1f5e 100644 --- a/src/wayland/wlr_layershell/wlr_layershell.hpp +++ b/src/wayland/wlr_layershell/wlr_layershell.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include #include @@ -196,6 +197,7 @@ private: 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_BINDABLE_PROPERTY(WlrLayershell, qint32, bcExclusiveZone); + Q_OBJECT_BINDABLE_PROPERTY(WlrLayershell, Qt::Edge, bcExclusionEdge); QS_BINDING_SUBSCRIBE_METHOD(WlrLayershell, bLayer, onStateChanged, onValueChanged); QS_BINDING_SUBSCRIBE_METHOD(WlrLayershell, bAnchors, onStateChanged, onValueChanged); diff --git a/src/window/panelinterface.hpp b/src/window/panelinterface.hpp index 22c47c98..64dff503 100644 --- a/src/window/panelinterface.hpp +++ b/src/window/panelinterface.hpp @@ -1,5 +1,6 @@ #pragma once +#include #include #include #include @@ -21,6 +22,21 @@ public: [[nodiscard]] bool horizontalConstraint() const noexcept { return this->mLeft && this->mRight; } [[nodiscard]] bool verticalConstraint() const noexcept { return this->mTop && this->mBottom; } + [[nodiscard]] Qt::Edge exclusionEdge() const noexcept { + auto hasHEdge = this->mLeft ^ this->mRight; + auto hasVEdge = this->mTop ^ this->mBottom; + + if (hasVEdge && !hasHEdge) { + if (this->mTop) return Qt::TopEdge; + if (this->mBottom) return Qt::BottomEdge; + } else if (hasHEdge && !hasVEdge) { + if (this->mLeft) return Qt::LeftEdge; + if (this->mRight) return Qt::RightEdge; + } + + return static_cast(0); + } + [[nodiscard]] bool operator==(const Anchors& other) const noexcept { // clang-format off return this->mLeft == other.mLeft