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

source code of kwayland/src/client/blur.cpp