Layershellqt

window.h
1/*
2 * SPDX-FileCopyrightText: 2021 Aleix Pol Gonzalez <aleixpol@blue-systems.com>
3 * SPDX-FileCopyrightText: 2018 Drew DeVault <sir@cmpwn.com>
4 *
5 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
6 */
7
8#ifndef LAYERSHELLQTWINDOW_H
9#define LAYERSHELLQTWINDOW_H
10
11#include <QObject>
12#include <QScreen>
13#include <QWindow>
14
15#include "layershellqt_export.h"
16
17namespace LayerShellQt
18{
19class WindowPrivate;
20
21class LAYERSHELLQT_EXPORT Window : public QObject
22{
23 Q_OBJECT
24 Q_PROPERTY(Anchors anchors READ anchors WRITE setAnchors NOTIFY anchorsChanged)
25 Q_PROPERTY(QString scope READ scope WRITE setScope)
26 Q_PROPERTY(QMargins margins READ margins WRITE setMargins NOTIFY marginsChanged)
27 Q_PROPERTY(qint32 exclusionZone READ exclusionZone WRITE setExclusiveZone NOTIFY exclusionZoneChanged)
28 Q_PROPERTY(Layer layer READ layer WRITE setLayer NOTIFY layerChanged)
29 Q_PROPERTY(KeyboardInteractivity keyboardInteractivity READ keyboardInteractivity WRITE setKeyboardInteractivity NOTIFY keyboardInteractivityChanged)
30 Q_PROPERTY(ScreenConfiguration screenConfiguration READ screenConfiguration WRITE setScreenConfiguration)
31
32public:
33 ~Window() override;
34
35 enum Anchor {
36 AnchorNone = 0,
37 AnchorTop = 1, ///< The top edge of the anchor rectangle
38 AnchorBottom = 2, ///< The bottom edge of the anchor rectangle
39 AnchorLeft = 4, ///< The left edge of the anchor rectangle
40 AnchorRight = 8, ///< The right edge of the anchor rectangle
41 };
42 Q_ENUM(Anchor);
43 Q_DECLARE_FLAGS(Anchors, Anchor)
44
45 /**
46 * This enum type is used to specify the layer where a surface can be put in.
47 */
48 enum Layer {
49 LayerBackground = 0,
50 LayerBottom = 1,
51 LayerTop = 2,
52 LayerOverlay = 3,
53 };
54 Q_ENUM(Layer)
55
56 /**
57 * This enum type is used to specify how the layer surface handles keyboard focus.
58 */
59 enum KeyboardInteractivity {
60 KeyboardInteractivityNone = 0,
61 KeyboardInteractivityExclusive = 1,
62 KeyboardInteractivityOnDemand = 2,
63 };
64 Q_ENUM(KeyboardInteractivity)
65
66 /**
67 * This enum type is used to specify which screen to place the surface on.
68 * ScreenFromQWindow (the default) reads QWindow::screen() while ScreenFromCompositor
69 * passes nil and lets the compositor decide.
70 */
71 enum ScreenConfiguration {
72 ScreenFromQWindow = 0,
73 ScreenFromCompositor = 1,
74 };
75 Q_ENUM(ScreenConfiguration)
76
77 void setAnchors(Anchors anchor);
78 Anchors anchors() const;
79
80 void setExclusiveZone(int32_t zone);
81 int32_t exclusionZone() const;
82
83 void setExclusiveEdge(Window::Anchor edge);
84 Window::Anchor exclusiveEdge() const;
85
86 void setMargins(const QMargins &margins);
87 QMargins margins() const;
88
89 void setDesiredSize(const QSize &size);
90 QSize desiredSize() const;
91
92 void setKeyboardInteractivity(KeyboardInteractivity interactivity);
93 KeyboardInteractivity keyboardInteractivity() const;
94
95 void setLayer(Layer layer);
96 Layer layer() const;
97
98 void setScreenConfiguration(ScreenConfiguration screenConfiguration);
99 ScreenConfiguration screenConfiguration() const;
100
101 /**
102 * Sets a string based identifier for this window.
103 * This may be used by a compositor to determine stacking
104 * order within a given layer.
105 *
106 * May also be referred to as a role
107 */
108 void setScope(const QString &scope);
109 QString scope() const;
110
111 /**
112 * Whether the QWindow should be closed when the layer surface is dismissed by the compositor.
113 * For example, if the associated screen has been removed.
114 *
115 * This can be used to map the window on another screen.
116 */
117 void setCloseOnDismissed(bool close);
118 bool closeOnDismissed() const;
119
120 /**
121 * Gets the LayerShell Window for a given Qt Window
122 * Ownership is not transferred
123 */
124 static Window *get(QWindow *window);
125
126 static Window *qmlAttachedProperties(QObject *object);
127
128Q_SIGNALS:
129 void anchorsChanged();
130 void exclusionZoneChanged();
131 void exclusiveEdgeChanged();
132 void marginsChanged();
133 void desiredSizeChanged();
134 void keyboardInteractivityChanged();
135 void layerChanged();
136
137private:
138 Window(QWindow *window);
139 QScopedPointer<WindowPrivate> d;
140};
141
142}
143
144#endif
KIOCORE_EXPORT TransferJob * get(const QUrl &url, LoadType reload=NoReload, JobFlags flags=DefaultFlags)
AnchorTop
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri May 2 2025 12:06:14 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.