8#include "../qwaylandlayershellintegration_p.h"
10#include <layershellqt_logging.h>
15#include <QtWaylandClient/private/qwaylandwindow_p.h>
17using namespace LayerShellQt;
19class LayerShellQt::WindowPrivate
22 WindowPrivate(QWindow *window)
27 QWindow *parentWindow;
28 QString scope = QStringLiteral(
"window");
29 Window::Anchors anchors = {Window::AnchorTop | Window::AnchorBottom | Window::AnchorLeft | Window::AnchorRight};
30 int32_t exclusionZone = 0;
31 Window::Anchor exclusiveEdge = Window::AnchorNone;
32 Window::KeyboardInteractivity keyboardInteractivity = Window::KeyboardInteractivityOnDemand;
33 Window::Layer layer = Window::LayerTop;
35 QSize desiredSize = QSize(0, 0);
36 Window::ScreenConfiguration screenConfiguration = Window::ScreenFromQWindow;
37 bool closeOnDismissed =
true;
44 s_map.remove(d->parentWindow);
47void Window::setAnchors(Anchors anchors)
49 if (d->anchors != anchors) {
55Window::Anchors Window::anchors()
const
60void Window::setExclusiveZone(int32_t zone)
62 if (d->exclusionZone != zone) {
63 d->exclusionZone = zone;
64 Q_EMIT exclusionZoneChanged();
68int32_t Window::exclusionZone()
const
70 return d->exclusionZone;
73void Window::setExclusiveEdge(Window::Anchor edge)
75 if (d->exclusiveEdge == edge) {
79 d->exclusiveEdge = edge;
80 Q_EMIT exclusiveEdgeChanged();
83Window::Anchor Window::exclusiveEdge()
const
85 return d->exclusiveEdge;
88void Window::setMargins(
const QMargins &margins)
90 if (d->margins != margins) {
101void Window::setDesiredSize(
const QSize &size)
103 if (size == d->desiredSize) {
107 d->desiredSize = size;
108 Q_EMIT desiredSizeChanged();
111QSize Window::desiredSize()
const
113 return d->desiredSize;
116void Window::setKeyboardInteractivity(KeyboardInteractivity interactivity)
118 if (d->keyboardInteractivity != interactivity) {
119 d->keyboardInteractivity = interactivity;
120 Q_EMIT keyboardInteractivityChanged();
124Window::KeyboardInteractivity Window::keyboardInteractivity()
const
126 return d->keyboardInteractivity;
129void Window::setLayer(Layer layer)
131 if (d->layer != layer) {
137void Window::setScope(
const QString &scope)
148Window::Layer Window::layer()
const
153Window::ScreenConfiguration Window::screenConfiguration()
const
155 return d->screenConfiguration;
158void Window::setScreenConfiguration(Window::ScreenConfiguration screenConfiguration)
160 d->screenConfiguration = screenConfiguration;
163bool Window::closeOnDismissed()
const
165 return d->closeOnDismissed;
168void Window::setCloseOnDismissed(
bool close)
170 d->closeOnDismissed =
close;
175 , d(new WindowPrivate(
window))
177 s_map.insert(d->parentWindow,
this);
181 auto waylandWindow =
dynamic_cast<QtWaylandClient::QWaylandWindow *
>(
window->handle());
182 if (!waylandWindow) {
183 qCWarning(LAYERSHELLQT) <<
window <<
"is not a wayland window. Not creating zwlr_layer_surface";
187 static QWaylandLayerShellIntegration *shellIntegration =
nullptr;
188 if (!shellIntegration) {
189 shellIntegration =
new QWaylandLayerShellIntegration();
190 if (!shellIntegration->initialize(waylandWindow->display())) {
191 delete shellIntegration;
192 shellIntegration =
nullptr;
193 qCWarning(LAYERSHELLQT) <<
"Failed to initialize layer-shell integration, possibly because compositor does not support the layer-shell protocol";
198 waylandWindow->setShellIntegration(shellIntegration);
207 auto layerShellWindow = s_map.value(window);
208 if (layerShellWindow) {
209 return layerShellWindow;
211 return new Window(window);
T qobject_cast(QObject *object)