KWayland

blur.h
1 /*
2  SPDX-FileCopyrightText: 2015 Martin Gräßlin <[email protected]>
3  SPDX-FileCopyrightText: 2015 Marco Martin <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
6 */
7 #ifndef KWAYLAND_BLUR_H
8 #define KWAYLAND_BLUR_H
9 
10 #include "buffer.h"
11 
12 #include <QObject>
13 #include <QPoint>
14 #include <QSize>
15 
16 #include <KWayland/Client/kwaylandclient_export.h>
17 
18 struct wl_buffer;
19 struct wl_region;
20 struct org_kde_kwin_blur;
21 struct org_kde_kwin_blur_manager;
22 
23 
24 namespace KWayland
25 {
26 namespace Client
27 {
28 class EventQueue;
29 class Blur;
30 class Surface;
31 class Region;
32 
33 /**
34  * TODO
35  */
36 class KWAYLANDCLIENT_EXPORT BlurManager : public QObject
37 {
38  Q_OBJECT
39 public:
40  /**
41  * Creates a new BlurManager.
42  * Note: after constructing the BlurManager it is not yet valid and one needs
43  * to call setup. In order to get a ready to use BlurManager prefer using
44  * Registry::createBlurManager.
45  **/
46  explicit BlurManager(QObject *parent = nullptr);
47  virtual ~BlurManager();
48 
49  /**
50  * @returns @c true if managing a org_kde_kwin_blur_manager.
51  **/
52  bool isValid() const;
53  /**
54  * Setup this BlurManager to manage the @p compositor.
55  * When using Registry::createBlurManager there is no need to call this
56  * method.
57  **/
58  void setup(org_kde_kwin_blur_manager *compositor);
59  /**
60  * Releases the org_kde_kwin_blur_manager interface.
61  * After the interface has been released the BlurManager instance is no
62  * longer valid and can be setup with another org_kde_kwin_blur_manager interface.
63  **/
64  void release();
65  /**
66  * Destroys the data held by this BlurManager.
67  * This method is supposed to be used when the connection to the Wayland
68  * server goes away. If the connection is not valid anymore, it's not
69  * possible to call release anymore as that calls into the Wayland
70  * connection and the call would fail. This method cleans up the data, so
71  * that the instance can be deleted or set up to a new org_kde_kwin_blur_manager interface
72  * once there is a new connection available.
73  *
74  * It is suggested to connect this method to ConnectionThread::connectionDied:
75  * @code
76  * connect(connection, &ConnectionThread::connectionDied, compositor, &BlurManager::destroy);
77  * @endcode
78  *
79  * @see release
80  **/
81  void destroy();
82 
83  /**
84  * Sets the @p queue to use for creating a Blur.
85  **/
86  void setEventQueue(EventQueue *queue);
87  /**
88  * @returns The event queue to use for creating a Blur.
89  **/
90  EventQueue *eventQueue();
91 
92  /**
93  * Creates and setup a new Blur with @p parent.
94  * @param parent The parent to pass to the Blur.
95  * @returns The new created Blur
96  **/
97  Blur *createBlur(Surface *surface, QObject *parent = nullptr);
98  void removeBlur(Surface *surface);
99 
100  operator org_kde_kwin_blur_manager *();
101  operator org_kde_kwin_blur_manager *() const;
102 
103 Q_SIGNALS:
104  /**
105  * The corresponding global for this interface on the Registry got removed.
106  *
107  * This signal gets only emitted if the BlurManager got created by
108  * Registry::createBlurManager
109  *
110  * @since 5.5
111  **/
112  void removed();
113 
114 private:
115  class Private;
117 };
118 
119 /**
120  * @short Wrapper for the org_kde_kwin_blur interface.
121  *
122  * This class is a convenient wrapper for the org_kde_kwin_blur interface.
123  * To create a Blur call BlurManager::createBlur.
124  *
125  * The main purpose of this class is to setup the next frame which
126  * should be rendered. Therefore it provides methods to add damage
127  * and to attach a new Buffer and to finalize the frame by calling
128  * commit.
129  *
130  * @see BlurManager
131  **/
132 class KWAYLANDCLIENT_EXPORT Blur : public QObject
133 {
134  Q_OBJECT
135 public:
136  virtual ~Blur();
137 
138  /**
139  * Setup this Blur to manage the @p blur.
140  * When using BlurManager::createBlur there is no need to call this
141  * method.
142  **/
143  void setup(org_kde_kwin_blur *blur);
144  /**
145  * Releases the org_kde_kwin_blur interface.
146  * After the interface has been released the Blur instance is no
147  * longer valid and can be setup with another org_kde_kwin_blur interface.
148  **/
149  void release();
150  /**
151  * Destroys the data held by this Blur.
152  * This method is supposed to be used when the connection to the Wayland
153  * server goes away. If the connection is not valid anymore, it's not
154  * possible to call release anymore as that calls into the Wayland
155  * connection and the call would fail. This method cleans up the data, so
156  * that the instance can be deleted or set up to a new org_kde_kwin_blur interface
157  * once there is a new connection available.
158  *
159  * This method is automatically invoked when the Registry which created this
160  * Blur gets destroyed.
161  *
162  * @see release
163  **/
164  void destroy();
165  /**
166  * @returns @c true if managing a org_kde_kwin_blur.
167  **/
168  bool isValid() const;
169 
170  void commit();
171 
172  /**
173  * Sets the area of the window that will have a blurred
174  * background.
175  * The region will have to be created with
176  * Compositor::createRegion(QRegion)
177  */
178  void setRegion(Region *region);
179 
180  operator org_kde_kwin_blur *();
181  operator org_kde_kwin_blur *() const;
182 
183 private:
184  friend class BlurManager;
185  explicit Blur(QObject *parent = nullptr);
186  class Private;
188 };
189 
190 }
191 }
192 
193 #endif
Wrapper for the org_kde_kwin_blur interface.
Definition: blur.h:132
Wrapper class for wl_event_queue interface.
Definition: event_queue.h:54
Wrapper for the wl_surface interface.
Definition: surface.h:43
Wrapper for the wl_region interface.
Definition: region.h:31
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Oct 25 2021 22:52:22 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.