mirror of
https://invent.kde.org/plasma/layer-shell-qt.git
synced 2025-05-25 09:30:22 -04:00
rename the api to setAnchorRect
This commit is contained in:
parent
94c82f2ed1
commit
29a4489c72
@ -34,7 +34,7 @@ public:
|
||||
QMargins margins;
|
||||
Window::ScreenConfiguration screenConfiguration = Window::ScreenFromQWindow;
|
||||
bool closeOnDismissed = true;
|
||||
bool accomodateExclusiveZones = true;
|
||||
Window::AnchorRect anchorRect = Window::AnchorRectWorkArea;
|
||||
};
|
||||
|
||||
static QMap<QWindow *, Window *> s_map;
|
||||
@ -85,19 +85,19 @@ Window::Anchor Window::exclusiveEdge() const
|
||||
return d->exclusiveEdge;
|
||||
}
|
||||
|
||||
bool Window::accomodateExclusiveZones() const
|
||||
Window::AnchorRect Window::anchorRect() const
|
||||
{
|
||||
return d->accomodateExclusiveZones;
|
||||
return d->anchorRect;
|
||||
}
|
||||
|
||||
void Window::setAccomodateExclusiveZones(bool accomodate)
|
||||
void Window::setAnchorRect(Window::AnchorRect anchorRect)
|
||||
{
|
||||
if (d->accomodateExclusiveZones == accomodate) {
|
||||
if (d->anchorRect == anchorRect) {
|
||||
return;
|
||||
}
|
||||
|
||||
d->accomodateExclusiveZones = accomodate;
|
||||
Q_EMIT accomodateExclusiveZonesChanged();
|
||||
d->anchorRect = anchorRect;
|
||||
Q_EMIT anchorRectChanged();
|
||||
}
|
||||
|
||||
void Window::setMargins(const QMargins &margins)
|
||||
|
@ -25,7 +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(AnchorRect anchorRect READ anchorRect WRITE setAnchorRect NOTIFY anchorRectChanged)
|
||||
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)
|
||||
@ -43,6 +43,12 @@ public:
|
||||
Q_ENUM(Anchor);
|
||||
Q_DECLARE_FLAGS(Anchors, Anchor)
|
||||
|
||||
/**
|
||||
* This enum is used to choose between anchoring to work area or screen area
|
||||
*/
|
||||
enum AnchorRect { AnchorRectWorkArea = 0, AnchorRectFullArea = 1 };
|
||||
Q_ENUM(AnchorRect);
|
||||
|
||||
/**
|
||||
* This enum type is used to specify the layer where a surface can be put in.
|
||||
*/
|
||||
@ -84,8 +90,8 @@ public:
|
||||
void setExclusiveEdge(Window::Anchor edge);
|
||||
Window::Anchor exclusiveEdge() const;
|
||||
|
||||
bool accomodateExclusiveZones() const;
|
||||
void setAccomodateExclusiveZones(bool accomodate);
|
||||
AnchorRect anchorRect() const;
|
||||
void setAnchorRect(AnchorRect anchorRect);
|
||||
|
||||
void setMargins(const QMargins &margins);
|
||||
QMargins margins() const;
|
||||
@ -130,7 +136,7 @@ Q_SIGNALS:
|
||||
void anchorsChanged();
|
||||
void exclusionZoneChanged();
|
||||
void exclusiveEdgeChanged();
|
||||
void accomodateExclusiveZonesChanged();
|
||||
void anchorRectChanged();
|
||||
void marginsChanged();
|
||||
void keyboardInteractivityChanged();
|
||||
void layerChanged();
|
||||
|
@ -56,9 +56,9 @@ QWaylandLayerSurface::QWaylandLayerSurface(QWaylandLayerShellIntegration *shell,
|
||||
setExclusiveEdge(m_interface->exclusiveEdge());
|
||||
});
|
||||
|
||||
setAccomodateExclusiveZones(m_interface->accomodateExclusiveZones());
|
||||
connect(m_interface, &Window::accomodateExclusiveZonesChanged, this, [this]() {
|
||||
setAccomodateExclusiveZones(m_interface->accomodateExclusiveZones());
|
||||
setAnchorRect(m_interface->anchorRect());
|
||||
connect(m_interface, &Window::anchorRectChanged, this, [this]() {
|
||||
setAnchorRect(m_interface->anchorRect());
|
||||
});
|
||||
|
||||
setMargins(m_interface->margins());
|
||||
@ -156,10 +156,10 @@ void QWaylandLayerSurface::setExclusiveEdge(uint32_t edge)
|
||||
}
|
||||
}
|
||||
|
||||
void QWaylandLayerSurface::setAccomodateExclusiveZones(bool accomodate)
|
||||
void QWaylandLayerSurface::setAnchorRect(int32_t anchorRect)
|
||||
{
|
||||
if (zwlr_layer_surface_v1_get_version(object()) >= ZWLR_LAYER_SURFACE_V1_SET_ACCOMODATE_EXCLUSIVE_ZONES_SINCE_VERSION) {
|
||||
set_accomodate_exclusive_zones(accomodate);
|
||||
if (zwlr_layer_surface_v1_get_version(object()) >= ZWLR_LAYER_SURFACE_V1_SET_ANCHOR_RECT_SINCE_VERSION) {
|
||||
set_anchor_rect(anchorRect);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
#ifndef _LAYERSURFACE_H
|
||||
#define _LAYERSURFACE_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <wayland-client.h>
|
||||
|
||||
#include "qwaylandlayershellintegration_p.h"
|
||||
@ -38,7 +39,7 @@ public:
|
||||
void setAnchor(uint32_t anchor);
|
||||
void setExclusiveZone(int32_t zone);
|
||||
void setExclusiveEdge(uint32_t edge);
|
||||
void setAccomodateExclusiveZones(bool accomodate);
|
||||
void setAnchorRect(int32_t anchorRect);
|
||||
void setMargins(const QMargins &margins);
|
||||
void setKeyboardInteractivity(uint32_t interactivity);
|
||||
void setLayer(uint32_t layer);
|
||||
|
@ -382,6 +382,11 @@
|
||||
<entry name="right" value="8" summary="the right edge of the anchor rectangle"/>
|
||||
</enum>
|
||||
|
||||
<enum name="anchor_rect">
|
||||
<entry name="anchor_rect_work_area" value="0" summary="use the anchor rectangle which takes into account all the other exclusive zones (default)"/>
|
||||
<entry name="anchor_rect_full_area" value="1" summary="use the whole screen area as the anchor rect, ignoring other exclusive zones"/>
|
||||
</enum>
|
||||
|
||||
<!-- Version 2 additions -->
|
||||
|
||||
<request name="set_layer" since="2">
|
||||
@ -411,18 +416,19 @@
|
||||
|
||||
<!-- 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.
|
||||
<request name="set_anchor_rect" since="6">
|
||||
<description summary="set which anchor rect to use to position the surface">
|
||||
When this surface is anchored, it can be to two possible anchor rects.
|
||||
|
||||
The accomodate parameter is treated as a boolean flag, a zero value means false,
|
||||
a non zero value means true.
|
||||
The work area rect (anchor_rect_work_area) is the usable space, excluding
|
||||
exclusive zones already claimed by other surfaces, ensuring no overlap will happen.
|
||||
This is the default behavior
|
||||
|
||||
This is the default behavior, if you want a zone to not be automatically moved,
|
||||
explicitly call this with 0 as parameter.
|
||||
The full area (anchor_rect_full_area) is the whole space of the screen, ensuring
|
||||
that the surface will touch all the screen edges corresponding to each anchor
|
||||
edge that was asked, even if this would result in overlapping surfaces.
|
||||
</description>
|
||||
<arg name="accomodate" type="uint"/>
|
||||
<arg name="anchor_rect" type="int" enum="anchor_rect"/>
|
||||
</request>
|
||||
|
||||
</interface>
|
||||
|
Loading…
Reference in New Issue
Block a user