Directory: | ./ |
---|---|
File: | src/client/wlr_output_manager_v1.cpp |
Date: | 2024-01-22 17:25:27 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 223 | 268 | 83.2% |
Branches: | 48 | 107 | 44.9% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | /**************************************************************************** | ||
2 | * Copyright © 2020 Roman Gilg <subdiff@gmail.com> | ||
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 | #include "wlr_output_manager_v1.h" | ||
21 | |||
22 | #include "event_queue.h" | ||
23 | #include "wayland_pointer_p.h" | ||
24 | #include "wlr_output_configuration_v1.h" | ||
25 | |||
26 | #include "wayland-wlr-output-management-v1-client-protocol.h" | ||
27 | |||
28 | #include <algorithm> | ||
29 | #include <vector> | ||
30 | |||
31 | namespace Wrapland | ||
32 | { | ||
33 | namespace Client | ||
34 | { | ||
35 | |||
36 | class Q_DECL_HIDDEN WlrOutputManagerV1::Private | ||
37 | { | ||
38 | public: | ||
39 | 3 | explicit Private(WlrOutputManagerV1* q) | |
40 | 3 | : q(q) | |
41 | { | ||
42 | 3 | } | |
43 | 3 | ~Private() = default; | |
44 | |||
45 | void setup(zwlr_output_manager_v1* manager); | ||
46 | |||
47 | WaylandPointer<zwlr_output_manager_v1, zwlr_output_manager_v1_destroy> outputManager; | ||
48 | 3 | EventQueue* queue = nullptr; | |
49 | |||
50 | static void headCallback(void* data, zwlr_output_manager_v1* manager, zwlr_output_head_v1* id); | ||
51 | static void doneCallback(void* data, zwlr_output_manager_v1* manager, quint32 serial); | ||
52 | static void finishedCallback(void* data, zwlr_output_manager_v1* manager); | ||
53 | |||
54 | WlrOutputManagerV1* q; | ||
55 | static const struct zwlr_output_manager_v1_listener s_listener; | ||
56 | |||
57 | quint32 serial; | ||
58 | }; | ||
59 | |||
60 | const zwlr_output_manager_v1_listener WlrOutputManagerV1::Private::s_listener = { | ||
61 | headCallback, | ||
62 | doneCallback, | ||
63 | finishedCallback, | ||
64 | }; | ||
65 | |||
66 | 6 | void WlrOutputManagerV1::Private::headCallback(void* data, | |
67 | zwlr_output_manager_v1* manager, | ||
68 | zwlr_output_head_v1* id) | ||
69 | { | ||
70 | 6 | auto d = reinterpret_cast<Private*>(data); | |
71 |
1/2✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
|
6 | Q_ASSERT(d->outputManager == manager); |
72 | |||
73 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
|
6 | auto head = new WlrOutputHeadV1(id, d->q); |
74 | 6 | Q_EMIT d->q->head(head); | |
75 | 6 | } | |
76 | |||
77 | 11 | void WlrOutputManagerV1::Private::doneCallback(void* data, | |
78 | zwlr_output_manager_v1* manager, | ||
79 | quint32 serial) | ||
80 | { | ||
81 | 11 | auto d = reinterpret_cast<Private*>(data); | |
82 |
1/2✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
|
11 | Q_ASSERT(d->outputManager == manager); |
83 | |||
84 | 11 | d->serial = serial; | |
85 | 11 | Q_EMIT d->q->done(); | |
86 | 11 | } | |
87 | |||
88 | ✗ | void WlrOutputManagerV1::Private::finishedCallback(void* data, zwlr_output_manager_v1* manager) | |
89 | { | ||
90 | ✗ | auto d = reinterpret_cast<Private*>(data); | |
91 | ✗ | Q_ASSERT(d->outputManager == manager); | |
92 | |||
93 | ✗ | Q_EMIT d->q->removed(); | |
94 | } | ||
95 | |||
96 | 3 | void WlrOutputManagerV1::Private::setup(zwlr_output_manager_v1* manager) | |
97 | { | ||
98 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | Q_ASSERT(manager); |
99 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | Q_ASSERT(!outputManager); |
100 | |||
101 | 3 | outputManager.setup(manager); | |
102 | 3 | zwlr_output_manager_v1_add_listener(manager, &s_listener, this); | |
103 | 3 | } | |
104 | |||
105 | 3 | WlrOutputManagerV1::WlrOutputManagerV1(QObject* parent) | |
106 | 3 | : QObject(parent) | |
107 |
2/4✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
|
3 | , d(new Private(this)) |
108 | 3 | { | |
109 | 3 | } | |
110 | |||
111 | 6 | WlrOutputManagerV1::~WlrOutputManagerV1() | |
112 | 6 | { | |
113 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | d->outputManager.release(); |
114 | 6 | } | |
115 | |||
116 | 3 | void WlrOutputManagerV1::setup(zwlr_output_manager_v1* outputManager) | |
117 | { | ||
118 | 3 | d->setup(outputManager); | |
119 | 3 | } | |
120 | |||
121 | ✗ | void WlrOutputManagerV1::release() | |
122 | { | ||
123 | ✗ | d->outputManager.release(); | |
124 | } | ||
125 | |||
126 | 3 | void WlrOutputManagerV1::setEventQueue(EventQueue* queue) | |
127 | { | ||
128 | 3 | d->queue = queue; | |
129 | 3 | } | |
130 | |||
131 | ✗ | EventQueue* WlrOutputManagerV1::eventQueue() | |
132 | { | ||
133 | ✗ | return d->queue; | |
134 | } | ||
135 | |||
136 | ✗ | WlrOutputManagerV1::operator zwlr_output_manager_v1*() | |
137 | { | ||
138 | ✗ | return d->outputManager; | |
139 | } | ||
140 | |||
141 | ✗ | WlrOutputManagerV1::operator zwlr_output_manager_v1*() const | |
142 | { | ||
143 | ✗ | return d->outputManager; | |
144 | } | ||
145 | |||
146 | ✗ | bool WlrOutputManagerV1::isValid() const | |
147 | { | ||
148 | ✗ | return d->outputManager.isValid(); | |
149 | } | ||
150 | |||
151 | 1 | WlrOutputConfigurationV1* WlrOutputManagerV1::createConfiguration(QObject* parent) | |
152 | { | ||
153 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | auto config = new WlrOutputConfigurationV1(parent); |
154 | 1 | auto w = zwlr_output_manager_v1_create_configuration(d->outputManager, d->serial); | |
155 | |||
156 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if (d->queue) { |
157 | 1 | d->queue->addProxy(w); | |
158 | 1 | } | |
159 | |||
160 | 1 | config->setup(w); | |
161 | 1 | return config; | |
162 | } | ||
163 | |||
164 | class Q_DECL_HIDDEN WlrOutputModeV1::Private | ||
165 | { | ||
166 | public: | ||
167 | Private(WlrOutputModeV1* q, zwlr_output_mode_v1* mode); | ||
168 | 18 | ~Private() = default; | |
169 | |||
170 | // TODO(romangg): release request only available starting version 3. | ||
171 | WaylandPointer<zwlr_output_mode_v1, zwlr_output_mode_v1_release> outputMode; | ||
172 | 18 | EventQueue* queue = nullptr; | |
173 | |||
174 | void name(QString const& name); | ||
175 | |||
176 | static void sizeCallback(void* data, zwlr_output_mode_v1* mode, int width, int height); | ||
177 | static void refreshCallback(void* data, zwlr_output_mode_v1* mode, int refresh); | ||
178 | static void preferredCallback(void* data, zwlr_output_mode_v1* mode); | ||
179 | static void finishedCallback(void* data, zwlr_output_mode_v1* mode); | ||
180 | |||
181 | WlrOutputModeV1* q; | ||
182 | static const struct zwlr_output_mode_v1_listener s_listener; | ||
183 | |||
184 | QSize size; | ||
185 | int refresh; | ||
186 | 18 | bool preferred = false; | |
187 | }; | ||
188 | |||
189 | const zwlr_output_mode_v1_listener WlrOutputModeV1::Private::s_listener = { | ||
190 | sizeCallback, | ||
191 | refreshCallback, | ||
192 | preferredCallback, | ||
193 | finishedCallback, | ||
194 | }; | ||
195 | |||
196 | 18 | void WlrOutputModeV1::Private::sizeCallback(void* data, | |
197 | zwlr_output_mode_v1* mode, | ||
198 | int width, | ||
199 | int height) | ||
200 | { | ||
201 | 18 | auto d = reinterpret_cast<Private*>(data); | |
202 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | Q_ASSERT(d->outputMode == mode); |
203 | |||
204 | 18 | d->size = QSize(width, height); | |
205 | 18 | } | |
206 | |||
207 | 18 | void WlrOutputModeV1::Private::refreshCallback(void* data, zwlr_output_mode_v1* mode, int refresh) | |
208 | { | ||
209 | 18 | auto d = reinterpret_cast<Private*>(data); | |
210 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | Q_ASSERT(d->outputMode == mode); |
211 | |||
212 | 18 | d->refresh = refresh; | |
213 | 18 | } | |
214 | |||
215 | 6 | void WlrOutputModeV1::Private::preferredCallback(void* data, zwlr_output_mode_v1* mode) | |
216 | { | ||
217 | 6 | auto d = reinterpret_cast<Private*>(data); | |
218 |
1/2✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
|
6 | Q_ASSERT(d->outputMode == mode); |
219 | |||
220 | 6 | d->preferred = true; | |
221 | 6 | } | |
222 | |||
223 | ✗ | void WlrOutputModeV1::Private::finishedCallback(void* data, zwlr_output_mode_v1* mode) | |
224 | { | ||
225 | ✗ | auto d = reinterpret_cast<Private*>(data); | |
226 | ✗ | Q_ASSERT(d->outputMode == mode); | |
227 | |||
228 | ✗ | Q_EMIT d->q->removed(); | |
229 | } | ||
230 | |||
231 | 36 | WlrOutputModeV1::Private::Private(WlrOutputModeV1* q, zwlr_output_mode_v1* mode) | |
232 | 18 | : q(q) | |
233 | { | ||
234 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | outputMode.setup(mode); |
235 |
2/4✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
|
18 | zwlr_output_mode_v1_add_listener(outputMode, &s_listener, this); |
236 | 18 | } | |
237 | |||
238 | 18 | WlrOutputModeV1::WlrOutputModeV1(zwlr_output_mode_v1* mode, QObject* parent) | |
239 | 18 | : QObject(parent) | |
240 |
2/4✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
|
18 | , d(new Private(this, mode)) |
241 | 18 | { | |
242 | 18 | } | |
243 | |||
244 | 36 | WlrOutputModeV1::~WlrOutputModeV1() = default; | |
245 | |||
246 | 3 | QSize WlrOutputModeV1::size() const | |
247 | { | ||
248 | 3 | return d->size; | |
249 | } | ||
250 | |||
251 | 3 | int WlrOutputModeV1::refresh() const | |
252 | { | ||
253 | 3 | return d->refresh; | |
254 | } | ||
255 | |||
256 | 3 | bool WlrOutputModeV1::preferred() const | |
257 | { | ||
258 | 3 | return d->preferred; | |
259 | } | ||
260 | |||
261 | class Q_DECL_HIDDEN WlrOutputHeadV1::Private | ||
262 | { | ||
263 | public: | ||
264 | Private(WlrOutputHeadV1* q, zwlr_output_head_v1* head); | ||
265 | 6 | ~Private() = default; | |
266 | |||
267 | // TODO(romangg): release request only available starting version 3. | ||
268 | WaylandPointer<zwlr_output_head_v1, zwlr_output_head_v1_release> outputHead; | ||
269 | 6 | EventQueue* queue = nullptr; | |
270 | |||
271 | static void nameCallback(void* data, zwlr_output_head_v1* head, char const* name); | ||
272 | static void descriptionCallback(void* data, zwlr_output_head_v1* head, char const* description); | ||
273 | static void physicalSizeCallback(void* data, zwlr_output_head_v1* head, int width, int height); | ||
274 | static void modeCallback(void* data, zwlr_output_head_v1* head, zwlr_output_mode_v1* mode); | ||
275 | static void enabledCallback(void* data, zwlr_output_head_v1* head, int enabled); | ||
276 | static void | ||
277 | currentModeCallback(void* data, zwlr_output_head_v1* head, zwlr_output_mode_v1* mode); | ||
278 | static void positionCallback(void* data, zwlr_output_head_v1* head, int x, int y); | ||
279 | static void transformCallback(void* data, zwlr_output_head_v1* head, int transform); | ||
280 | static void scaleCallback(void* data, zwlr_output_head_v1* head, wl_fixed_t scale); | ||
281 | static void finishedCallback(void* data, zwlr_output_head_v1* head); | ||
282 | |||
283 | static void makeCallback(void* data, zwlr_output_head_v1* head, char const* make); | ||
284 | static void modelCallback(void* data, zwlr_output_head_v1* head, char const* model); | ||
285 | static void | ||
286 | serialNumberCallback(void* data, zwlr_output_head_v1* head, char const* serialNumber); | ||
287 | static void adaptive_sync_callback(void* data, zwlr_output_head_v1* head, uint32_t state); | ||
288 | |||
289 | WlrOutputHeadV1* q; | ||
290 | static const struct zwlr_output_head_v1_listener s_listener; | ||
291 | |||
292 | QString name; | ||
293 | QString description; | ||
294 | QSize physicalSize; | ||
295 | QPoint position; | ||
296 | 6 | Transform transform{Transform::Normal}; | |
297 | 6 | bool enabled{false}; | |
298 | 6 | double scale{1.}; | |
299 | 6 | bool adapt_sync{false}; | |
300 | |||
301 | QString make; | ||
302 | QString model; | ||
303 | QString serialNumber; | ||
304 | |||
305 | std::vector<std::unique_ptr<WlrOutputModeV1>> modes; | ||
306 | 6 | WlrOutputModeV1* currentMode{nullptr}; | |
307 | |||
308 | private: | ||
309 | WlrOutputModeV1* getMode(zwlr_output_mode_v1* mode) const; | ||
310 | }; | ||
311 | |||
312 | const zwlr_output_head_v1_listener WlrOutputHeadV1::Private::s_listener = { | ||
313 | nameCallback, | ||
314 | descriptionCallback, | ||
315 | physicalSizeCallback, | ||
316 | modeCallback, | ||
317 | enabledCallback, | ||
318 | currentModeCallback, | ||
319 | positionCallback, | ||
320 | transformCallback, | ||
321 | scaleCallback, | ||
322 | finishedCallback, | ||
323 | makeCallback, | ||
324 | modelCallback, | ||
325 | serialNumberCallback, | ||
326 | adaptive_sync_callback, | ||
327 | }; | ||
328 | |||
329 | 6 | void WlrOutputHeadV1::Private::nameCallback(void* data, zwlr_output_head_v1* head, char const* name) | |
330 | { | ||
331 | 6 | auto d = reinterpret_cast<Private*>(data); | |
332 |
1/2✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
|
6 | Q_ASSERT(d->outputHead == head); |
333 | |||
334 | 6 | d->name = name; | |
335 | 6 | Q_EMIT d->q->changed(); | |
336 | 6 | } | |
337 | |||
338 | 6 | void WlrOutputHeadV1::Private::descriptionCallback(void* data, | |
339 | zwlr_output_head_v1* head, | ||
340 | char const* description) | ||
341 | { | ||
342 | 6 | auto d = reinterpret_cast<Private*>(data); | |
343 |
1/2✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
|
6 | Q_ASSERT(d->outputHead == head); |
344 | |||
345 | 6 | d->description = description; | |
346 | 6 | Q_EMIT d->q->changed(); | |
347 | 6 | } | |
348 | |||
349 | ✗ | void WlrOutputHeadV1::Private::physicalSizeCallback(void* data, | |
350 | zwlr_output_head_v1* head, | ||
351 | int width, | ||
352 | int height) | ||
353 | { | ||
354 | ✗ | auto d = reinterpret_cast<Private*>(data); | |
355 | ✗ | Q_ASSERT(d->outputHead == head); | |
356 | |||
357 | ✗ | d->physicalSize = QSize(width, height); | |
358 | ✗ | Q_EMIT d->q->changed(); | |
359 | } | ||
360 | |||
361 | 18 | void WlrOutputHeadV1::Private::modeCallback(void* data, | |
362 | zwlr_output_head_v1* head, | ||
363 | zwlr_output_mode_v1* mode) | ||
364 | { | ||
365 | 18 | auto d = reinterpret_cast<Private*>(data); | |
366 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | Q_ASSERT(d->outputHead == head); |
367 | |||
368 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | auto mode_wrapper = new WlrOutputModeV1(mode, d->q); |
369 | 18 | connect(mode_wrapper, &WlrOutputModeV1::removed, d->q, [d, mode_wrapper] { | |
370 | ✗ | auto it = std::find_if( | |
371 | ✗ | d->modes.begin(), d->modes.end(), [mode_wrapper](auto const& stored_mode) { | |
372 | ✗ | return mode_wrapper == stored_mode.get(); | |
373 | }); | ||
374 | ✗ | assert(it != d->modes.end()); | |
375 | ✗ | d->modes.erase(it); | |
376 | ✗ | if (mode_wrapper == d->currentMode) { | |
377 | ✗ | d->currentMode = nullptr; | |
378 | ✗ | Q_EMIT d->q->changed(); | |
379 | } | ||
380 | ✗ | }); | |
381 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
|
18 | d->modes.push_back(std::unique_ptr<WlrOutputModeV1>{mode_wrapper}); |
382 | |||
383 | 18 | Q_EMIT d->q->changed(); | |
384 | 18 | } | |
385 | |||
386 | 9 | void WlrOutputHeadV1::Private::enabledCallback(void* data, zwlr_output_head_v1* head, int enabled) | |
387 | { | ||
388 | 9 | auto d = reinterpret_cast<Private*>(data); | |
389 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | Q_ASSERT(d->outputHead == head); |
390 | |||
391 | 9 | d->enabled = enabled; | |
392 | 9 | Q_EMIT d->q->changed(); | |
393 | 9 | } | |
394 | |||
395 | 6 | void WlrOutputHeadV1::Private::currentModeCallback(void* data, | |
396 | zwlr_output_head_v1* head, | ||
397 | zwlr_output_mode_v1* mode) | ||
398 | { | ||
399 | 6 | auto d = reinterpret_cast<Private*>(data); | |
400 |
1/2✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
|
6 | Q_ASSERT(d->outputHead == head); |
401 | |||
402 | 6 | d->currentMode = d->getMode(mode); | |
403 | 6 | Q_EMIT d->q->changed(); | |
404 | 6 | } | |
405 | |||
406 | 6 | WlrOutputModeV1* WlrOutputHeadV1::Private::getMode(zwlr_output_mode_v1* mode) const | |
407 | { | ||
408 |
1/2✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
|
9 | for (auto const& modeWrapper : modes) { |
409 | 9 | auto raw_ptr = modeWrapper.get(); | |
410 |
2/2✓ Branch 0 taken 6 times.
✓ Branch 1 taken 3 times.
|
9 | if (mode == *raw_ptr) { |
411 | 6 | return raw_ptr; | |
412 | } | ||
413 | } | ||
414 | ✗ | return nullptr; | |
415 | 6 | } | |
416 | |||
417 | 10 | WlrOutputModeV1::operator zwlr_output_mode_v1*() | |
418 | { | ||
419 | 10 | return d->outputMode; | |
420 | } | ||
421 | |||
422 | ✗ | WlrOutputModeV1::operator zwlr_output_mode_v1*() const | |
423 | { | ||
424 | ✗ | return d->outputMode; | |
425 | } | ||
426 | |||
427 | 6 | void WlrOutputHeadV1::Private::positionCallback(void* data, zwlr_output_head_v1* head, int x, int y) | |
428 | { | ||
429 | 6 | auto d = reinterpret_cast<Private*>(data); | |
430 |
1/2✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
|
6 | Q_ASSERT(d->outputHead == head); |
431 | |||
432 | 6 | d->position = QPoint(x, y); | |
433 | 6 | Q_EMIT d->q->changed(); | |
434 | 6 | } | |
435 | |||
436 | 6 | void WlrOutputHeadV1::Private::transformCallback(void* data, | |
437 | zwlr_output_head_v1* head, | ||
438 | int transform) | ||
439 | { | ||
440 | 6 | auto d = reinterpret_cast<Private*>(data); | |
441 |
1/2✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
|
6 | Q_ASSERT(d->outputHead == head); |
442 | |||
443 | 12 | auto toTransform = [transform]() { | |
444 |
2/9✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
|
6 | switch (transform) { |
445 | case WL_OUTPUT_TRANSFORM_90: | ||
446 | ✗ | return Transform::Rotated90; | |
447 | case WL_OUTPUT_TRANSFORM_180: | ||
448 | ✗ | return Transform::Rotated180; | |
449 | case WL_OUTPUT_TRANSFORM_270: | ||
450 | ✗ | return Transform::Rotated270; | |
451 | case WL_OUTPUT_TRANSFORM_FLIPPED: | ||
452 | ✗ | return Transform::Flipped; | |
453 | case WL_OUTPUT_TRANSFORM_FLIPPED_90: | ||
454 | ✗ | return Transform::Flipped90; | |
455 | case WL_OUTPUT_TRANSFORM_FLIPPED_180: | ||
456 | 2 | return Transform::Flipped180; | |
457 | case WL_OUTPUT_TRANSFORM_FLIPPED_270: | ||
458 | ✗ | return Transform::Flipped270; | |
459 | 4 | case WL_OUTPUT_TRANSFORM_NORMAL: | |
460 | default: | ||
461 | 4 | return Transform::Normal; | |
462 | } | ||
463 | 6 | }; | |
464 | 6 | d->transform = toTransform(); | |
465 | 6 | Q_EMIT d->q->changed(); | |
466 | 6 | } | |
467 | |||
468 | 6 | void WlrOutputHeadV1::Private::scaleCallback(void* data, | |
469 | zwlr_output_head_v1* head, | ||
470 | wl_fixed_t scale) | ||
471 | { | ||
472 | 6 | auto d = reinterpret_cast<Private*>(data); | |
473 |
1/2✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
|
6 | Q_ASSERT(d->outputHead == head); |
474 | |||
475 | 6 | d->scale = wl_fixed_to_double(scale); | |
476 | 6 | Q_EMIT d->q->changed(); | |
477 | 6 | } | |
478 | |||
479 | 2 | void WlrOutputHeadV1::Private::finishedCallback(void* data, zwlr_output_head_v1* head) | |
480 | { | ||
481 | 2 | auto d = reinterpret_cast<Private*>(data); | |
482 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | Q_ASSERT(d->outputHead == head); |
483 | |||
484 | 2 | Q_EMIT d->q->removed(); | |
485 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | delete d->q; |
486 | 2 | } | |
487 | |||
488 | 6 | void WlrOutputHeadV1::Private::makeCallback(void* data, zwlr_output_head_v1* head, char const* make) | |
489 | { | ||
490 | 6 | auto d = reinterpret_cast<Private*>(data); | |
491 |
1/2✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
|
6 | Q_ASSERT(d->outputHead == head); |
492 | |||
493 | 6 | d->make = make; | |
494 | 6 | Q_EMIT d->q->changed(); | |
495 | 6 | } | |
496 | |||
497 | 6 | void WlrOutputHeadV1::Private::modelCallback(void* data, | |
498 | zwlr_output_head_v1* head, | ||
499 | char const* model) | ||
500 | { | ||
501 | 6 | auto d = reinterpret_cast<Private*>(data); | |
502 |
1/2✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
|
6 | Q_ASSERT(d->outputHead == head); |
503 | |||
504 | 6 | d->model = model; | |
505 | 6 | Q_EMIT d->q->changed(); | |
506 | 6 | } | |
507 | |||
508 | 6 | void WlrOutputHeadV1::Private::serialNumberCallback(void* data, | |
509 | zwlr_output_head_v1* head, | ||
510 | char const* serialNumber) | ||
511 | { | ||
512 | 6 | auto d = reinterpret_cast<Private*>(data); | |
513 |
1/2✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
|
6 | Q_ASSERT(d->outputHead == head); |
514 | |||
515 | 6 | d->serialNumber = serialNumber; | |
516 | 6 | Q_EMIT d->q->changed(); | |
517 | 6 | } | |
518 | |||
519 | 6 | void WlrOutputHeadV1::Private::adaptive_sync_callback(void* data, | |
520 | zwlr_output_head_v1* head, | ||
521 | uint32_t state) | ||
522 | { | ||
523 | 6 | auto d = reinterpret_cast<Private*>(data); | |
524 |
1/2✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
|
6 | Q_ASSERT(d->outputHead == head); |
525 | |||
526 | 6 | d->adapt_sync = state == ZWLR_OUTPUT_HEAD_V1_ADAPTIVE_SYNC_STATE_ENABLED; | |
527 | 6 | Q_EMIT d->q->changed(); | |
528 | 6 | } | |
529 | |||
530 | 18 | WlrOutputHeadV1::Private::Private(WlrOutputHeadV1* q, zwlr_output_head_v1* head) | |
531 | 6 | : q(q) | |
532 | { | ||
533 |
1/2✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
|
6 | outputHead.setup(head); |
534 |
2/4✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
|
6 | zwlr_output_head_v1_add_listener(outputHead, &s_listener, this); |
535 | 6 | } | |
536 | |||
537 | 6 | WlrOutputHeadV1::WlrOutputHeadV1(zwlr_output_head_v1* head, QObject* parent) | |
538 | 6 | : QObject(parent) | |
539 |
2/4✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
|
6 | , d(new Private(this, head)) |
540 | 6 | { | |
541 | 6 | } | |
542 | |||
543 | 12 | WlrOutputHeadV1::~WlrOutputHeadV1() = default; | |
544 | |||
545 | 3 | QString WlrOutputHeadV1::name() const | |
546 | { | ||
547 | 3 | return d->name; | |
548 | } | ||
549 | |||
550 | 3 | QString WlrOutputHeadV1::description() const | |
551 | { | ||
552 | 3 | return d->description; | |
553 | } | ||
554 | |||
555 | 3 | QString WlrOutputHeadV1::make() const | |
556 | { | ||
557 | 3 | return d->make; | |
558 | } | ||
559 | |||
560 | 3 | QString WlrOutputHeadV1::model() const | |
561 | { | ||
562 | 3 | return d->model; | |
563 | } | ||
564 | |||
565 | 3 | QString WlrOutputHeadV1::serialNumber() const | |
566 | { | ||
567 | 3 | return d->serialNumber; | |
568 | } | ||
569 | |||
570 | ✗ | QSize WlrOutputHeadV1::physicalSize() const | |
571 | { | ||
572 | ✗ | return d->physicalSize; | |
573 | } | ||
574 | |||
575 | 4 | QPoint WlrOutputHeadV1::position() const | |
576 | { | ||
577 | 4 | return d->position; | |
578 | } | ||
579 | |||
580 | 4 | WlrOutputHeadV1::Transform WlrOutputHeadV1::transform() const | |
581 | { | ||
582 | 4 | return d->transform; | |
583 | } | ||
584 | |||
585 | 6 | bool WlrOutputHeadV1::enabled() const | |
586 | { | ||
587 | 6 | return d->enabled; | |
588 | } | ||
589 | |||
590 | 4 | double WlrOutputHeadV1::scale() const | |
591 | { | ||
592 | 4 | return d->scale; | |
593 | } | ||
594 | |||
595 | 4 | bool WlrOutputHeadV1::adaptive_sync() const | |
596 | { | ||
597 | 4 | return d->adapt_sync; | |
598 | } | ||
599 | |||
600 | 6 | QVector<WlrOutputModeV1*> WlrOutputHeadV1::modes() const | |
601 | { | ||
602 | 6 | QVector<WlrOutputModeV1*> ret; | |
603 |
2/2✓ Branch 0 taken 6 times.
✓ Branch 1 taken 16 times.
|
22 | for (auto const& mode : d->modes) { |
604 |
1/2✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
|
16 | ret.append(mode.get()); |
605 | } | ||
606 | 6 | return ret; | |
607 |
1/2✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
|
6 | } |
608 | |||
609 | 14 | WlrOutputModeV1* WlrOutputHeadV1::currentMode() const | |
610 | { | ||
611 | 14 | return d->currentMode; | |
612 | } | ||
613 | |||
614 | 2 | WlrOutputHeadV1::operator zwlr_output_head_v1*() | |
615 | { | ||
616 | 2 | return d->outputHead; | |
617 | } | ||
618 | |||
619 | ✗ | WlrOutputHeadV1::operator zwlr_output_head_v1*() const | |
620 | { | ||
621 | ✗ | return d->outputHead; | |
622 | } | ||
623 | |||
624 | } | ||
625 | } | ||
626 |