1 | /* |
---|---|
2 | SPDX-FileCopyrightText: 2015 Marco Martin <notmart@gmail.com> |
3 | |
4 | SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL |
5 | */ |
6 | #include "slide.h" |
7 | #include "event_queue.h" |
8 | #include "surface.h" |
9 | #include "wayland_pointer_p.h" |
10 | |
11 | #include <wayland-slide-client-protocol.h> |
12 | |
13 | namespace KWayland |
14 | { |
15 | namespace Client |
16 | { |
17 | class Q_DECL_HIDDEN SlideManager::Private |
18 | { |
19 | public: |
20 | Private() = default; |
21 | |
22 | WaylandPointer<org_kde_kwin_slide_manager, org_kde_kwin_slide_manager_destroy> slidemanager; |
23 | EventQueue *queue = nullptr; |
24 | }; |
25 | |
26 | SlideManager::SlideManager(QObject *parent) |
27 | : QObject(parent) |
28 | , d(new Private) |
29 | { |
30 | } |
31 | |
32 | SlideManager::~SlideManager() |
33 | { |
34 | release(); |
35 | } |
36 | |
37 | void SlideManager::setup(org_kde_kwin_slide_manager *slidemanager) |
38 | { |
39 | Q_ASSERT(slidemanager); |
40 | Q_ASSERT(!d->slidemanager); |
41 | d->slidemanager.setup(pointer: slidemanager); |
42 | } |
43 | |
44 | void SlideManager::release() |
45 | { |
46 | d->slidemanager.release(); |
47 | } |
48 | |
49 | void SlideManager::destroy() |
50 | { |
51 | d->slidemanager.destroy(); |
52 | } |
53 | |
54 | void SlideManager::setEventQueue(EventQueue *queue) |
55 | { |
56 | d->queue = queue; |
57 | } |
58 | |
59 | EventQueue *SlideManager::eventQueue() |
60 | { |
61 | return d->queue; |
62 | } |
63 | |
64 | SlideManager::operator org_kde_kwin_slide_manager *() |
65 | { |
66 | return d->slidemanager; |
67 | } |
68 | |
69 | SlideManager::operator org_kde_kwin_slide_manager *() const |
70 | { |
71 | return d->slidemanager; |
72 | } |
73 | |
74 | bool SlideManager::isValid() const |
75 | { |
76 | return d->slidemanager.isValid(); |
77 | } |
78 | |
79 | Slide *SlideManager::createSlide(Surface *surface, QObject *parent) |
80 | { |
81 | Q_ASSERT(isValid()); |
82 | Slide *s = new Slide(parent); |
83 | auto w = org_kde_kwin_slide_manager_create(org_kde_kwin_slide_manager: d->slidemanager, surface: *surface); |
84 | if (d->queue) { |
85 | d->queue->addProxy(proxy: w); |
86 | } |
87 | s->setup(w); |
88 | return s; |
89 | } |
90 | |
91 | void SlideManager::removeSlide(Surface *surface) |
92 | { |
93 | org_kde_kwin_slide_manager_unset(org_kde_kwin_slide_manager: d->slidemanager, surface: *surface); |
94 | } |
95 | |
96 | class Slide::Private |
97 | { |
98 | public: |
99 | Private() = default; |
100 | |
101 | WaylandPointer<org_kde_kwin_slide, org_kde_kwin_slide_release> slide; |
102 | }; |
103 | |
104 | Slide::Slide(QObject *parent) |
105 | : QObject(parent) |
106 | , d(new Private) |
107 | { |
108 | } |
109 | |
110 | Slide::~Slide() |
111 | { |
112 | release(); |
113 | } |
114 | |
115 | void Slide::setup(org_kde_kwin_slide *slide) |
116 | { |
117 | Q_ASSERT(slide); |
118 | Q_ASSERT(!d->slide); |
119 | d->slide.setup(pointer: slide); |
120 | } |
121 | |
122 | void Slide::release() |
123 | { |
124 | d->slide.release(); |
125 | } |
126 | |
127 | void Slide::destroy() |
128 | { |
129 | d->slide.destroy(); |
130 | } |
131 | |
132 | Slide::operator org_kde_kwin_slide *() |
133 | { |
134 | return d->slide; |
135 | } |
136 | |
137 | Slide::operator org_kde_kwin_slide *() const |
138 | { |
139 | return d->slide; |
140 | } |
141 | |
142 | bool Slide::isValid() const |
143 | { |
144 | return d->slide.isValid(); |
145 | } |
146 | |
147 | void Slide::commit() |
148 | { |
149 | Q_ASSERT(isValid()); |
150 | org_kde_kwin_slide_commit(org_kde_kwin_slide: d->slide); |
151 | } |
152 | |
153 | void Slide::setLocation(Slide::Location location) |
154 | { |
155 | org_kde_kwin_slide_set_location(org_kde_kwin_slide: d->slide, location); |
156 | } |
157 | |
158 | void Slide::setOffset(qint32 offset) |
159 | { |
160 | org_kde_kwin_slide_set_offset(org_kde_kwin_slide: d->slide, offset); |
161 | } |
162 | |
163 | } |
164 | } |
165 | |
166 | #include "moc_slide.cpp" |
167 |