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
This commit is contained in:
Marco Martin 2024-05-02 15:28:00 +02:00
parent 05de6c67b2
commit 96b27d54ab
6 changed files with 48 additions and 3 deletions

View File

@ -34,6 +34,7 @@ public:
QMargins margins; QMargins margins;
Window::ScreenConfiguration screenConfiguration = Window::ScreenFromQWindow; Window::ScreenConfiguration screenConfiguration = Window::ScreenFromQWindow;
bool closeOnDismissed = true; bool closeOnDismissed = true;
bool accomodateExclusiveZones = true;
}; };
static QMap<QWindow *, Window *> s_map; static QMap<QWindow *, Window *> s_map;
@ -84,6 +85,21 @@ Window::Anchor Window::exclusiveEdge() const
return d->exclusiveEdge; 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) void Window::setMargins(const QMargins &margins)
{ {
if (d->margins != margins) { if (d->margins != margins) {

View File

@ -25,6 +25,7 @@ class LAYERSHELLQT_EXPORT Window : public QObject
Q_PROPERTY(QString scope READ scope WRITE setScope) Q_PROPERTY(QString scope READ scope WRITE setScope)
Q_PROPERTY(QMargins margins READ margins WRITE setMargins NOTIFY marginsChanged) Q_PROPERTY(QMargins margins READ margins WRITE setMargins NOTIFY marginsChanged)
Q_PROPERTY(qint32 exclusionZone READ exclusionZone WRITE setExclusiveZone NOTIFY exclusionZoneChanged) 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(Layer layer READ layer WRITE setLayer NOTIFY layerChanged)
Q_PROPERTY(KeyboardInteractivity keyboardInteractivity READ keyboardInteractivity WRITE setKeyboardInteractivity NOTIFY keyboardInteractivityChanged) Q_PROPERTY(KeyboardInteractivity keyboardInteractivity READ keyboardInteractivity WRITE setKeyboardInteractivity NOTIFY keyboardInteractivityChanged)
Q_PROPERTY(ScreenConfiguration screenConfiguration READ screenConfiguration WRITE setScreenConfiguration) Q_PROPERTY(ScreenConfiguration screenConfiguration READ screenConfiguration WRITE setScreenConfiguration)
@ -83,6 +84,9 @@ public:
void setExclusiveEdge(Window::Anchor edge); void setExclusiveEdge(Window::Anchor edge);
Window::Anchor exclusiveEdge() const; Window::Anchor exclusiveEdge() const;
bool accomodateExclusiveZones() const;
void setAccomodateExclusiveZones(bool accomodate);
void setMargins(const QMargins &margins); void setMargins(const QMargins &margins);
QMargins margins() const; QMargins margins() const;
@ -126,6 +130,7 @@ Q_SIGNALS:
void anchorsChanged(); void anchorsChanged();
void exclusionZoneChanged(); void exclusionZoneChanged();
void exclusiveEdgeChanged(); void exclusiveEdgeChanged();
void accomodateExclusiveZonesChanged();
void marginsChanged(); void marginsChanged();
void keyboardInteractivityChanged(); void keyboardInteractivityChanged();
void layerChanged(); void layerChanged();

View File

@ -15,7 +15,7 @@
namespace LayerShellQt namespace LayerShellQt
{ {
QWaylandLayerShellIntegration::QWaylandLayerShellIntegration() QWaylandLayerShellIntegration::QWaylandLayerShellIntegration()
: QWaylandShellIntegrationTemplate<QWaylandLayerShellIntegration>(5) : QWaylandShellIntegrationTemplate<QWaylandLayerShellIntegration>(6)
, m_xdgActivation(new QWaylandXdgActivationV1) , m_xdgActivation(new QWaylandXdgActivationV1)
{ {
} }

View File

@ -56,6 +56,11 @@ QWaylandLayerSurface::QWaylandLayerSurface(QWaylandLayerShellIntegration *shell,
setExclusiveEdge(m_interface->exclusiveEdge()); setExclusiveEdge(m_interface->exclusiveEdge());
}); });
setAccomodateExclusiveZones(m_interface->accomodateExclusiveZones());
connect(m_interface, &Window::accomodateExclusiveZonesChanged, this, [this]() {
setAccomodateExclusiveZones(m_interface->accomodateExclusiveZones());
});
setMargins(m_interface->margins()); setMargins(m_interface->margins());
connect(m_interface, &Window::marginsChanged, this, [this]() { connect(m_interface, &Window::marginsChanged, this, [this]() {
setMargins(m_interface->margins()); setMargins(m_interface->margins());
@ -147,6 +152,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) void QWaylandLayerSurface::setMargins(const QMargins &margins)
{ {
set_margin(margins.top(), margins.right(), margins.bottom(), margins.left()); set_margin(margins.top(), margins.right(), margins.bottom(), margins.left());

View File

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

View File

@ -25,7 +25,7 @@
THIS SOFTWARE. THIS SOFTWARE.
</copyright> </copyright>
<interface name="zwlr_layer_shell_v1" version="5"> <interface name="zwlr_layer_shell_v1" version="6">
<description summary="create surfaces that are layers of the desktop"> <description summary="create surfaces that are layers of the desktop">
Clients can use this interface to assign the surface_layer role to 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 wl_surfaces. Such surfaces are assigned to a "layer" of the output and
@ -100,7 +100,7 @@
</request> </request>
</interface> </interface>
<interface name="zwlr_layer_surface_v1" version="5"> <interface name="zwlr_layer_surface_v1" version="6">
<description summary="layer metadata interface"> <description summary="layer metadata interface">
An interface that may be implemented by a wl_surface, for surfaces that 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 are designed to be rendered as a layer of a stacked desktop-like
@ -403,5 +403,16 @@
</description> </description>
<arg name="edge" type="uint"/> <arg name="edge" type="uint"/>
</request> </request>
<!-- Version 6 additions -->
<request name="set_accomodate_exclusive_zones" since="6">
<description summary="set whether accomodate exclusive zones of other surfaces">
Asks for this surface to not be automatically moved and resized according
to exclusive zones claimed by other surfaces.
</description>
<arg name="accomodate" type="uint"/>
</request>
</interface> </interface>
</protocol> </protocol>