diff --git a/src/interfaces/window.cpp b/src/interfaces/window.cpp index 5dbd8cc..e387cb4 100644 --- a/src/interfaces/window.cpp +++ b/src/interfaces/window.cpp @@ -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) { diff --git a/src/interfaces/window.h b/src/interfaces/window.h index 8a5bf95..9b476a4 100644 --- a/src/interfaces/window.h +++ b/src/interfaces/window.h @@ -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(); diff --git a/src/qwaylandlayershellintegration.cpp b/src/qwaylandlayershellintegration.cpp index 8d90d26..d980ab0 100644 --- a/src/qwaylandlayershellintegration.cpp +++ b/src/qwaylandlayershellintegration.cpp @@ -15,7 +15,7 @@ namespace LayerShellQt { QWaylandLayerShellIntegration::QWaylandLayerShellIntegration() - : QWaylandShellIntegrationTemplate(4) + : QWaylandShellIntegrationTemplate(5) , m_xdgActivation(new QWaylandXdgActivationV1) { } diff --git a/src/qwaylandlayersurface.cpp b/src/qwaylandlayersurface.cpp index 89f47ef..15ffc1d 100644 --- a/src/qwaylandlayersurface.cpp +++ b/src/qwaylandlayersurface.cpp @@ -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,13 @@ void QWaylandLayerSurface::setExclusiveZone(int32_t zone) set_exclusive_zone(zone); } +void QWaylandLayerSurface::setExclusiveEdge(uint32_t edge) +{ + if (zwlr_layer_surface_v1_get_version(object()) >= ZWLR_LAYER_SURFACE_V1_SET_EXCLUSIVE_EDGE_SINCE_VERSION) { + set_exclusive_edge(edge); + } +} + void QWaylandLayerSurface::setMargins(const QMargins &margins) { set_margin(margins.top(), margins.right(), margins.bottom(), margins.left()); diff --git a/src/qwaylandlayersurface_p.h b/src/qwaylandlayersurface_p.h index 9ccf819..c61e514 100644 --- a/src/qwaylandlayersurface_p.h +++ b/src/qwaylandlayersurface_p.h @@ -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); diff --git a/src/wlr-layer-shell-unstable-v1.xml b/src/wlr-layer-shell-unstable-v1.xml index b53f7a8..ba4bb61 100644 --- a/src/wlr-layer-shell-unstable-v1.xml +++ b/src/wlr-layer-shell-unstable-v1.xml @@ -25,7 +25,7 @@ THIS SOFTWARE. - + Clients can use this interface to assign the surface_layer role to wl_surfaces. Such surfaces are assigned to a "layer" of the output and @@ -100,7 +100,7 @@ - + An interface that may be implemented by a wl_surface, for surfaces that are designed to be rendered as a layer of a stacked desktop-like @@ -367,6 +367,7 @@ + @@ -386,5 +387,21 @@ + + + + + + Requests an edge for the exclusive zone to apply. The exclusive + edge will be automatically deduced from anchor points when possible, + but when the surface is anchored to a corner, it will be necessary + to set it explicitly to disambiguate, as it is not possible to deduce + which one of the two corner edges should be used. + + The edge must be one the surface is anchored to, otherwise the + invalid_exclusive_edge protocol error will be raised. + + +