Skip to content

Commit 3b4ebc5

Browse files
committed
wayland/layershell: support auto exclusive zone without constraint
1 parent bb206e3 commit 3b4ebc5

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

src/wayland/wlr_layershell/wlr_layershell.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "wlr_layershell.hpp"
22

33
#include <qlogging.h>
4+
#include <qnamespace.h>
45
#include <qobject.h>
56
#include <qqmllist.h>
67
#include <qquickitem.h>
@@ -20,13 +21,15 @@ WlrLayershell::WlrLayershell(QObject* parent): ProxyWindowBase(parent) {
2021
case ExclusionMode::Ignore: return -1;
2122
case ExclusionMode::Normal: return this->bExclusiveZone;
2223
case ExclusionMode::Auto:
23-
const auto anchors = this->bAnchors.value();
24+
const auto edge = this->bcExclusionEdge.value();
2425

25-
if (anchors.horizontalConstraint()) return this->bImplicitHeight;
26-
else if (anchors.verticalConstraint()) return this->bImplicitWidth;
26+
if (edge == Qt::TopEdge || edge == Qt::BottomEdge) return this->bImplicitHeight;
27+
else if (edge == Qt::LeftEdge || edge == Qt::RightEdge) return this->bImplicitWidth;
2728
else return 0;
2829
}
2930
});
31+
32+
this->bcExclusionEdge.setBinding([this] { return this->bAnchors.value().exclusionEdge(); });
3033
}
3134

3235
ProxiedWindow* WlrLayershell::retrieveWindow(QObject* oldInstance) {

src/wayland/wlr_layershell/wlr_layershell.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#pragma once
22

33
#include <qcontainerfwd.h>
4+
#include <qnamespace.h>
45
#include <qobject.h>
56
#include <qproperty.h>
67
#include <qqmlintegration.h>
@@ -196,6 +197,7 @@ private slots:
196197
Q_OBJECT_BINDABLE_PROPERTY(WlrLayershell, WlrKeyboardFocus::Enum, bKeyboardFocus, &WlrLayershell::keyboardFocusChanged);
197198
Q_OBJECT_BINDABLE_PROPERTY_WITH_ARGS(WlrLayershell, ExclusionMode::Enum, bExclusionMode, ExclusionMode::Auto, &WlrLayershell::exclusionModeChanged);
198199
Q_OBJECT_BINDABLE_PROPERTY(WlrLayershell, qint32, bcExclusiveZone);
200+
Q_OBJECT_BINDABLE_PROPERTY(WlrLayershell, Qt::Edge, bcExclusionEdge);
199201

200202
QS_BINDING_SUBSCRIBE_METHOD(WlrLayershell, bLayer, onStateChanged, onValueChanged);
201203
QS_BINDING_SUBSCRIBE_METHOD(WlrLayershell, bAnchors, onStateChanged, onValueChanged);

src/window/panelinterface.hpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#pragma once
22

3+
#include <qnamespace.h>
34
#include <qqmlintegration.h>
45
#include <qtmetamacros.h>
56
#include <qtypes.h>
@@ -21,6 +22,21 @@ class Anchors {
2122
[[nodiscard]] bool horizontalConstraint() const noexcept { return this->mLeft && this->mRight; }
2223
[[nodiscard]] bool verticalConstraint() const noexcept { return this->mTop && this->mBottom; }
2324

25+
[[nodiscard]] Qt::Edge exclusionEdge() const noexcept {
26+
auto hasHEdge = this->mLeft ^ this->mRight;
27+
auto hasVEdge = this->mTop ^ this->mBottom;
28+
29+
if (hasVEdge && !hasHEdge) {
30+
if (this->mTop) return Qt::TopEdge;
31+
if (this->mBottom) return Qt::BottomEdge;
32+
} else if (hasHEdge && !hasVEdge) {
33+
if (this->mLeft) return Qt::LeftEdge;
34+
if (this->mRight) return Qt::RightEdge;
35+
}
36+
37+
return static_cast<Qt::Edge>(0);
38+
}
39+
2440
[[nodiscard]] bool operator==(const Anchors& other) const noexcept {
2541
// clang-format off
2642
return this->mLeft == other.mLeft

0 commit comments

Comments
 (0)