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 setKeyboardInteractivity(KeyboardInteractivity interactivity);
90 KeyboardInteractivity keyboardInteractivity() const;
91
92 void setLayer(Layer layer);
93 Layer layer() const;
94
95 void setScreenConfiguration(ScreenConfiguration screenConfiguration);
96 ScreenConfiguration screenConfiguration() const;
97
98 /**
99 * Sets a string based identifier for this window.
100 * This may be used by a compositor to determine stacking
101 * order within a given layer.
102 *
103 * May also be referred to as a role
104 */
105 void setScope(const QString &scope);
106 QString scope() const;
107
108 /**
109 * Whether the QWindow should be closed when the layer surface is dismissed by the compositor.
110 * For example, if the associated screen has been removed.
111 *
112 * This can be used to map the window on another screen.
113 */
114 void setCloseOnDismissed(bool close);
115 bool closeOnDismissed() const;
116
117 /**
118 * Gets the LayerShell Window for a given Qt Window
119 * Ownership is not transferred
120 */
121 static Window *get(QWindow *window);
122
123 static Window *qmlAttachedProperties(QObject *object);
124
125Q_SIGNALS:
126 void anchorsChanged();
127 void exclusionZoneChanged();
128 void exclusiveEdgeChanged();
129 void marginsChanged();
130 void keyboardInteractivityChanged();
131 void layerChanged();
132
133private:
134 Window(QWindow *window);
136};
137
138}
139
140#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-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:02:40 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.