GCC Code Coverage Report


Directory: ./
File: src/client/xdgdecoration.h
Date: 2024-01-22 17:25:27
Exec Total Coverage
Lines: 1 1 100.0%
Branches: 0 0 -%

Line Branch Exec Source
1 /****************************************************************************
2 Copyright 2018 David Edmundson <kde@davidedmundson.co.uk>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) version 3, or any
8 later version accepted by the membership of KDE e.V. (or its
9 successor approved by the membership of KDE e.V.), which shall
10 act as a proxy defined in Section 6 of version 3 of the license.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library. If not, see <http://www.gnu.org/licenses/>.
19 ****************************************************************************/
20 #ifndef WRAPLAND_CLIENT_XDG_DECORATION_UNSTABLE_V1_H
21 #define WRAPLAND_CLIENT_XDG_DECORATION_UNSTABLE_V1_H
22
23 #include <QObject>
24 // STD
25 #include <Wrapland/Client/wraplandclient_export.h>
26 #include <memory>
27
28 struct zxdg_decoration_manager_v1;
29 struct zxdg_toplevel_decoration_v1;
30
31 namespace Wrapland
32 {
33 namespace Client
34 {
35
36 class EventQueue;
37 class XdgDecoration;
38 class XdgShellToplevel;
39
40 /**
41 * @short Wrapper for the zxdg_decoration_manager_v1 interface.
42 *
43 * This class provides a convenient wrapper for the zxdg_decoration_manager_v1 interface.
44 *
45 * To use this class one needs to interact with the Registry. There are two
46 * possible ways to create the XdgDecorationManager interface:
47 * @code
48 * XdgDecorationManager *c = registry->createXdgDecorationManager(name, version);
49 * @endcode
50 *
51 * This creates the XdgDecorationManager and sets it up directly. As an alternative this
52 * can also be done in a more low level way:
53 * @code
54 * XdgDecorationManager *c = new XdgDecorationManager;
55 * c->setup(registry->bindXdgDecorationManager(name, version));
56 * @endcode
57 *
58 * The XdgDecorationManager can be used as a drop-in replacement for any zxdg_decoration_manager_v1
59 * pointer as it provides matching cast operators.
60 *
61 * If you use the QtWayland QPA you do not need to use this class.
62 *
63 * @see Registry
64 * @since 0.0.554
65 **/
66 class WRAPLANDCLIENT_EXPORT XdgDecorationManager : public QObject
67 {
68 Q_OBJECT
69 public:
70 /**
71 * Creates a new XdgDecorationManager.
72 * Note: after constructing the XdgDecorationManager it is not yet valid and one needs
73 * to call setup. In order to get a ready to use XdgDecorationManager prefer using
74 * Registry::createXdgDecorationManager.
75 **/
76 explicit XdgDecorationManager(QObject* parent = nullptr);
77 virtual ~XdgDecorationManager();
78
79 /**
80 * Setup this XdgDecorationManager to manage the @p xdgdecorationmanager.
81 * When using Registry::createXdgDecorationManager there is no need to call this
82 * method.
83 **/
84 void setup(zxdg_decoration_manager_v1* xdgdecorationmanager);
85 /**
86 * @returns @c true if managing a zxdg_decoration_manager_v1.
87 **/
88 bool isValid() const;
89 /**
90 * Releases the zxdg_decoration_manager_v1 interface.
91 * After the interface has been released the XdgDecorationManager instance is no
92 * longer valid and can be setup with another zxdg_decoration_manager_v1 interface.
93 **/
94 void release();
95
96 /**
97 * Sets the @p queue to use for creating objects with this XdgDecorationManager.
98 **/
99 void setEventQueue(EventQueue* queue);
100 /**
101 * @returns The event queue to use for creating objects with this XdgDecorationManager.
102 **/
103 EventQueue* eventQueue();
104
105 XdgDecoration* getToplevelDecoration(XdgShellToplevel* toplevel, QObject* parent = nullptr);
106
107 operator zxdg_decoration_manager_v1*();
108 operator zxdg_decoration_manager_v1*() const;
109
110 Q_SIGNALS:
111 /**
112 * The corresponding global for this interface on the Registry got removed.
113 *
114 * This signal gets only emitted if the XdgDecorationManager got created by
115 * Registry::createXdgDecorationManager
116 **/
117 void removed();
118
119 private:
120 class Private;
121 std::unique_ptr<Private> d;
122 };
123
124 class WRAPLANDCLIENT_EXPORT XdgDecoration : public QObject
125 {
126 Q_OBJECT
127 public:
128 enum class Mode {
129 ClientSide,
130 ServerSide,
131 };
132
133 2 Q_ENUM(Mode)
134
135 virtual ~XdgDecoration();
136
137 /**
138 * Setup this XdgDecoration to manage the @p xdgdecoration.
139 * When using XdgDecorationManager::createXdgDecoration there is no need to call this
140 * method.
141 **/
142 void setup(zxdg_toplevel_decoration_v1* xdgdecoration);
143 /**
144 * @returns @c true if managing a zxdg_toplevel_decoration_v1.
145 **/
146 bool isValid() const;
147 /**
148 * Releases the zxdg_toplevel_decoration_v1 interface.
149 * After the interface has been released the XdgDecoration instance is no
150 * longer valid and can be setup with another zxdg_toplevel_decoration_v1 interface.
151 **/
152 void release();
153
154 /**
155 * @brief Request that the server puts us in a given mode. The compositor will respond with a
156 * modeChange The compositor may ignore this request.
157 */
158 void setMode(Mode mode);
159
160 /**
161 * @brief Unset our requested mode. The compositor can then configure this surface with the
162 * default mode
163 */
164 void unsetMode();
165
166 /**
167 * The mode configured by the server.
168 */
169 Mode mode() const;
170
171 operator zxdg_toplevel_decoration_v1*();
172 operator zxdg_toplevel_decoration_v1*() const;
173
174 Q_SIGNALS:
175 void modeChanged(Wrapland::Client::XdgDecoration::Mode mode);
176
177 private:
178 friend class XdgDecorationManager;
179 explicit XdgDecoration(QObject* parent = nullptr);
180 class Private;
181 std::unique_ptr<Private> d;
182 };
183
184 }
185 }
186
187 #endif
188