Add a new setExclusiveEdge call in the protocol

This can be used to disambiguate the exclusive edge when the anchors are
on a corner (so there  would be 2 candidates)

it's quite quick and dirty mostly to understand if we do want to push
for something along the lines
This commit is contained in:
Marco Martin 2023-12-21 15:38:31 +01:00
parent 7d3194034c
commit 856843a22f
5 changed files with 35 additions and 0 deletions

View File

@ -28,6 +28,7 @@ public:
QString scope = QStringLiteral("window");
Window::Anchors anchors = {Window::AnchorTop | Window::AnchorBottom | Window::AnchorLeft | Window::AnchorRight};
int32_t exclusionZone = 0;
Window::Anchor exclusiveEdge = Window::AnchorNone;
Window::KeyboardInteractivity keyboardInteractivity = Window::KeyboardInteractivityOnDemand;
Window::Layer layer = Window::LayerTop;
QMargins margins;
@ -68,6 +69,21 @@ int32_t Window::exclusionZone() const
return d->exclusionZone;
}
void Window::setExclusiveEdge(Window::Anchor edge)
{
if (d->exclusiveEdge == edge) {
return;
}
d->exclusiveEdge = edge;
Q_EMIT exclusiveEdgeChanged();
}
Window::Anchor Window::exclusiveEdge() const
{
return d->exclusiveEdge;
}
void Window::setMargins(const QMargins &margins)
{
if (d->margins != margins) {

View File

@ -33,6 +33,7 @@ public:
~Window() override;
enum Anchor {
AnchorNone = 0,
AnchorTop = 1, ///< The top edge of the anchor rectangle
AnchorBottom = 2, ///< The bottom edge of the anchor rectangle
AnchorLeft = 4, ///< The left edge of the anchor rectangle
@ -79,6 +80,9 @@ public:
void setExclusiveZone(int32_t zone);
int32_t exclusionZone() const;
void setExclusiveEdge(Window::Anchor edge);
Window::Anchor exclusiveEdge() const;
void setMargins(const QMargins &margins);
QMargins margins() const;
@ -121,6 +125,7 @@ public:
Q_SIGNALS:
void anchorsChanged();
void exclusionZoneChanged();
void exclusiveEdgeChanged();
void marginsChanged();
void keyboardInteractivityChanged();
void layerChanged();

View File

@ -48,6 +48,10 @@ QWaylandLayerSurface::QWaylandLayerSurface(QWaylandLayerShellIntegration *shell,
connect(m_interface, &Window::exclusionZoneChanged, this, [this]() {
setExclusiveZone(m_interface->exclusionZone());
});
setExclusiveEdge(m_interface->exclusiveEdge());
connect(m_interface, &Window::exclusiveEdgeChanged, this, [this]() {
setExclusiveEdge(m_interface->exclusiveEdge());
});
setMargins(m_interface->margins());
connect(m_interface, &Window::marginsChanged, this, [this]() {
@ -127,6 +131,11 @@ void QWaylandLayerSurface::setExclusiveZone(int32_t zone)
set_exclusive_zone(zone);
}
void QWaylandLayerSurface::setExclusiveEdge(uint32_t edge)
{
set_exclusive_edge(edge);
}
void QWaylandLayerSurface::setMargins(const QMargins &margins)
{
set_margin(margins.top(), margins.right(), margins.bottom(), margins.left());

View File

@ -36,6 +36,7 @@ public:
void setAnchor(uint32_t anchor);
void setExclusiveZone(int32_t zone);
void setExclusiveEdge(uint32_t edge);
void setMargins(const QMargins &margins);
void setKeyboardInteractivity(uint32_t interactivity);
void setLayer(uint32_t layer);

View File

@ -187,6 +187,10 @@
<arg name="zone" type="int"/>
</request>
<request name="set_exclusive_edge">
<arg name="edge" type="uint"/>
</request>
<request name="set_margin">
<description summary="sets a margin from the anchor point">
Requests that the surface be placed some distance away from the anchor