From fc462d18a6a1d129c386b96af4f683b84e509283 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Thu, 2 May 2024 15:28:00 +0200 Subject: [PATCH] Add set_accomodate_exclusive_zones call Add a new method that tells the surface whether to accomodate exclusive zones set by other surfaces or not. right until now this was possible by setting the eclusive zone of this surface to the value of -1. Besides being a magic number, it makes impossible for this surface to set an exclusive zone by itself if we want to ignore other exclusive zones --- src/interfaces/window.cpp | 16 ++++++++++++++++ src/interfaces/window.h | 5 +++++ src/qwaylandlayershellintegration.cpp | 2 +- src/qwaylandlayersurface.cpp | 12 ++++++++++++ src/qwaylandlayersurface_p.h | 1 + src/wlr-layer-shell-unstable-v1.xml | 15 +++++++++++++-- 6 files changed, 48 insertions(+), 3 deletions(-) diff --git a/src/interfaces/window.cpp b/src/interfaces/window.cpp index 7fd962f..3e8fa05 100644 --- a/src/interfaces/window.cpp +++ b/src/interfaces/window.cpp @@ -34,6 +34,7 @@ public: QMargins margins; Window::ScreenConfiguration screenConfiguration = Window::ScreenFromQWindow; bool closeOnDismissed = true; + bool accomodateExclusiveZones = true; }; static QMap s_map; @@ -84,6 +85,21 @@ Window::Anchor Window::exclusiveEdge() const return d->exclusiveEdge; } +bool Window::accomodateExclusiveZones() const +{ + return d->accomodateExclusiveZones; +} + +void Window::setAccomodateExclusiveZones(bool accomodate) +{ + if (d->accomodateExclusiveZones == accomodate) { + return; + } + + d->accomodateExclusiveZones = accomodate; + Q_EMIT accomodateExclusiveZonesChanged(); +} + void Window::setMargins(const QMargins &margins) { if (d->margins != margins) { diff --git a/src/interfaces/window.h b/src/interfaces/window.h index 389a6df..da24f0a 100644 --- a/src/interfaces/window.h +++ b/src/interfaces/window.h @@ -25,6 +25,7 @@ class LAYERSHELLQT_EXPORT Window : public QObject Q_PROPERTY(QString scope READ scope WRITE setScope) Q_PROPERTY(QMargins margins READ margins WRITE setMargins NOTIFY marginsChanged) Q_PROPERTY(qint32 exclusionZone READ exclusionZone WRITE setExclusiveZone NOTIFY exclusionZoneChanged) + Q_PROPERTY(bool accomodateExclusiveZones READ accomodateExclusiveZones WRITE setAccomodateExclusiveZones NOTIFY accomodateExclusiveZonesChanged) Q_PROPERTY(Layer layer READ layer WRITE setLayer NOTIFY layerChanged) Q_PROPERTY(KeyboardInteractivity keyboardInteractivity READ keyboardInteractivity WRITE setKeyboardInteractivity NOTIFY keyboardInteractivityChanged) Q_PROPERTY(ScreenConfiguration screenConfiguration READ screenConfiguration WRITE setScreenConfiguration) @@ -83,6 +84,9 @@ public: void setExclusiveEdge(Window::Anchor edge); Window::Anchor exclusiveEdge() const; + bool accomodateExclusiveZones() const; + void setAccomodateExclusiveZones(bool accomodate); + void setMargins(const QMargins &margins); QMargins margins() const; @@ -126,6 +130,7 @@ Q_SIGNALS: void anchorsChanged(); void exclusionZoneChanged(); void exclusiveEdgeChanged(); + void accomodateExclusiveZonesChanged(); void marginsChanged(); void keyboardInteractivityChanged(); void layerChanged(); diff --git a/src/qwaylandlayershellintegration.cpp b/src/qwaylandlayershellintegration.cpp index 2ae367e..b772cc9 100644 --- a/src/qwaylandlayershellintegration.cpp +++ b/src/qwaylandlayershellintegration.cpp @@ -15,7 +15,7 @@ namespace LayerShellQt { QWaylandLayerShellIntegration::QWaylandLayerShellIntegration() - : QWaylandShellIntegrationTemplate(5) + : QWaylandShellIntegrationTemplate(6) , m_xdgActivation(new QWaylandXdgActivationV1) { } diff --git a/src/qwaylandlayersurface.cpp b/src/qwaylandlayersurface.cpp index c03de35..f35f6b8 100644 --- a/src/qwaylandlayersurface.cpp +++ b/src/qwaylandlayersurface.cpp @@ -56,6 +56,11 @@ QWaylandLayerSurface::QWaylandLayerSurface(QWaylandLayerShellIntegration *shell, setExclusiveEdge(m_interface->exclusiveEdge()); }); + setAccomodateExclusiveZones(m_interface->accomodateExclusiveZones()); + connect(m_interface, &Window::accomodateExclusiveZonesChanged, this, [this]() { + setAccomodateExclusiveZones(m_interface->accomodateExclusiveZones()); + }); + setMargins(m_interface->margins()); connect(m_interface, &Window::marginsChanged, this, [this]() { setMargins(m_interface->margins()); @@ -151,6 +156,13 @@ void QWaylandLayerSurface::setExclusiveEdge(uint32_t edge) } } +void QWaylandLayerSurface::setAccomodateExclusiveZones(bool accomodate) +{ + if (zwlr_layer_surface_v1_get_version(object()) >= ZWLR_LAYER_SURFACE_V1_SET_ACCOMODATE_EXCLUSIVE_ZONES_SINCE_VERSION) { + set_accomodate_exclusive_zones(accomodate); + } +} + 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 079a295..0d5c81e 100644 --- a/src/qwaylandlayersurface_p.h +++ b/src/qwaylandlayersurface_p.h @@ -38,6 +38,7 @@ public: void setAnchor(uint32_t anchor); void setExclusiveZone(int32_t zone); void setExclusiveEdge(uint32_t edge); + void setAccomodateExclusiveZones(bool accomodate); 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 ba4bb61..9aa069b 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 @@ -403,5 +403,16 @@ + + + + + + Asks for this surface to not be automatically moved and resized according + to exclusive zones claimed by other surfaces. + + + +