forked from quickshell/quickshell
wayland/layershell: support auto exclusive zone without constraint
This commit is contained in:
parent
bb206e3a19
commit
3b4ebc5f16
3 changed files with 24 additions and 3 deletions
|
@ -1,6 +1,7 @@
|
|||
#include "wlr_layershell.hpp"
|
||||
|
||||
#include <qlogging.h>
|
||||
#include <qnamespace.h>
|
||||
#include <qobject.h>
|
||||
#include <qqmllist.h>
|
||||
#include <qquickitem.h>
|
||||
|
@ -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) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <qcontainerfwd.h>
|
||||
#include <qnamespace.h>
|
||||
#include <qobject.h>
|
||||
#include <qproperty.h>
|
||||
#include <qqmlintegration.h>
|
||||
|
@ -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);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <qnamespace.h>
|
||||
#include <qqmlintegration.h>
|
||||
#include <qtmetamacros.h>
|
||||
#include <qtypes.h>
|
||||
|
@ -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<Qt::Edge>(0);
|
||||
}
|
||||
|
||||
[[nodiscard]] bool operator==(const Anchors& other) const noexcept {
|
||||
// clang-format off
|
||||
return this->mLeft == other.mLeft
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue