KWayland

contrast.cpp
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 #include "contrast.h"
8 #include "event_queue.h"
9 #include "region.h"
10 #include "surface.h"
11 #include "wayland_pointer_p.h"
12 
13 #include <wayland-contrast-client-protocol.h>
14 
15 namespace KWayland
16 {
17 
18 namespace Client
19 {
20 
21 class Q_DECL_HIDDEN ContrastManager::Private
22 {
23 public:
24  Private() = default;
25 
26  WaylandPointer<org_kde_kwin_contrast_manager, org_kde_kwin_contrast_manager_destroy> manager;
27  EventQueue *queue = nullptr;
28 };
29 
31  : QObject(parent)
32  , d(new Private)
33 {
34 }
35 
36 ContrastManager::~ContrastManager()
37 {
38  release();
39 }
40 
42 {
43  d->manager.release();
44 }
45 
47 {
48  d->manager.destroy();
49 }
50 
52 {
53  return d->manager.isValid();
54 }
55 
56 void ContrastManager::setup(org_kde_kwin_contrast_manager *manager)
57 {
58  Q_ASSERT(manager);
59  Q_ASSERT(!d->manager);
60  d->manager.setup(manager);
61 }
62 
64 {
65  d->queue = queue;
66 }
67 
69 {
70  return d->queue;
71 }
72 
74 {
75  Q_ASSERT(isValid());
76  Contrast *s = new Contrast(parent);
77  auto w = org_kde_kwin_contrast_manager_create(d->manager, *surface);
78  if (d->queue) {
79  d->queue->addProxy(w);
80  }
81  s->setup(w);
82  return s;
83 }
84 
85 void ContrastManager::removeContrast(Surface *surface)
86 {
87  Q_ASSERT(isValid());
88  org_kde_kwin_contrast_manager_unset(d->manager, *surface);
89 }
90 
91 ContrastManager::operator org_kde_kwin_contrast_manager*()
92 {
93  return d->manager;
94 }
95 
96 ContrastManager::operator org_kde_kwin_contrast_manager*() const
97 {
98  return d->manager;
99 }
100 
101 class Contrast::Private
102 {
103 public:
104  WaylandPointer<org_kde_kwin_contrast, org_kde_kwin_contrast_release> contrast;
105 };
106 
107 Contrast::Contrast(QObject *parent)
108  : QObject(parent)
109  , d(new Private)
110 {
111 }
112 
113 Contrast::~Contrast()
114 {
115  release();
116 }
117 
119 {
120  d->contrast.release();
121 }
122 
123 void Contrast::setup(org_kde_kwin_contrast *contrast)
124 {
125  Q_ASSERT(contrast);
126  Q_ASSERT(!d->contrast);
127  d->contrast.setup(contrast);
128 }
129 
131 {
132  d->contrast.destroy();
133 }
134 
135 bool Contrast::isValid() const
136 {
137  return d->contrast.isValid();
138 }
139 
140 void Contrast::commit()
141 {
142  Q_ASSERT(isValid());
143  org_kde_kwin_contrast_commit(d->contrast);
144 }
145 
147 {
148  org_kde_kwin_contrast_set_region(d->contrast, *region);
149 }
150 
151 void Contrast::setContrast(qreal contrast)
152 {
153  org_kde_kwin_contrast_set_contrast(d->contrast, wl_fixed_from_double(contrast));
154 }
155 
156 void Contrast::setIntensity(qreal intensity)
157 {
158  org_kde_kwin_contrast_set_intensity(d->contrast, wl_fixed_from_double(intensity));
159 }
160 
161 void Contrast::setSaturation(qreal saturation)
162 {
163  org_kde_kwin_contrast_set_saturation(d->contrast, wl_fixed_from_double(saturation));
164 }
165 
166 Contrast::operator org_kde_kwin_contrast*()
167 {
168  return d->contrast;
169 }
170 
171 Contrast::operator org_kde_kwin_contrast*() const
172 {
173  return d->contrast;
174 }
175 
176 }
177 }
void destroy()
Destroys the data held by this Contrast.
Definition: contrast.cpp:130
Wrapper for the org_kde_kwin_contrast interface.
Definition: contrast.h:128
void setup(org_kde_kwin_contrast_manager *contrastManager)
Setup this ContrastManager to manage the contrastManager.
Definition: contrast.cpp:56
Wrapper class for wl_event_queue interface.
Definition: event_queue.h:55
void release()
Releases the org_kde_kwin_contrast_manager interface.
Definition: contrast.cpp:41
void destroy()
Destroys the data held by this ContrastManager.
Definition: contrast.cpp:46
void setRegion(Region *region)
Sets the area of the window that will have a contrasted background.
Definition: contrast.cpp:146
void setup(org_kde_kwin_contrast *contrast)
Setup this Contrast to manage the contrast.
Definition: contrast.cpp:123
Wrapper for the wl_surface interface.
Definition: surface.h:44
ContrastManager(QObject *parent=nullptr)
Creates a new ContrastManager.
Definition: contrast.cpp:30
void setEventQueue(EventQueue *queue)
Sets the queue to use for creating a Contrast.
Definition: contrast.cpp:63
Contrast * createContrast(Surface *surface, QObject *parent=nullptr)
Creates and setup a new Contrast with parent.
Definition: contrast.cpp:73
QObject(QObject *parent)
void release()
Releases the org_kde_kwin_contrast interface.
Definition: contrast.cpp:118
QObject * parent() const const
Wrapper for the wl_region interface.
Definition: region.h:32
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Wed Jul 8 2020 22:48:48 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.