KWayland

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

KDE's Doxygen guidelines are available online.