KWayland

blur.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 "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 
15 namespace KWayland
16 {
17 namespace Client
18 {
19 class Q_DECL_HIDDEN BlurManager::Private
20 {
21 public:
22  Private() = default;
23 
24  WaylandPointer<org_kde_kwin_blur_manager, org_kde_kwin_blur_manager_destroy> manager;
25  EventQueue *queue = nullptr;
26 };
27 
29  : QObject(parent)
30  , d(new Private)
31 {
32 }
33 
34 BlurManager::~BlurManager()
35 {
36  release();
37 }
38 
40 {
41  d->manager.release();
42 }
43 
45 {
46  d->manager.destroy();
47 }
48 
50 {
51  return d->manager.isValid();
52 }
53 
54 void BlurManager::setup(org_kde_kwin_blur_manager *manager)
55 {
56  Q_ASSERT(manager);
57  Q_ASSERT(!d->manager);
58  d->manager.setup(manager);
59 }
60 
62 {
63  d->queue = queue;
64 }
65 
67 {
68  return d->queue;
69 }
70 
72 {
73  Q_ASSERT(isValid());
74  Blur *s = new Blur(parent);
75  auto w = org_kde_kwin_blur_manager_create(d->manager, *surface);
76  if (d->queue) {
77  d->queue->addProxy(w);
78  }
79  s->setup(w);
80  return s;
81 }
82 
83 void BlurManager::removeBlur(Surface *surface)
84 {
85  Q_ASSERT(isValid());
86  org_kde_kwin_blur_manager_unset(d->manager, *surface);
87 }
88 
89 BlurManager::operator org_kde_kwin_blur_manager *()
90 {
91  return d->manager;
92 }
93 
94 BlurManager::operator org_kde_kwin_blur_manager *() const
95 {
96  return d->manager;
97 }
98 
99 class Blur::Private
100 {
101 public:
102  WaylandPointer<org_kde_kwin_blur, org_kde_kwin_blur_release> blur;
103 };
104 
105 Blur::Blur(QObject *parent)
106  : QObject(parent)
107  , d(new Private)
108 {
109 }
110 
111 Blur::~Blur()
112 {
113  release();
114 }
115 
117 {
118  d->blur.release();
119 }
120 
121 void Blur::setup(org_kde_kwin_blur *blur)
122 {
123  Q_ASSERT(blur);
124  Q_ASSERT(!d->blur);
125  d->blur.setup(blur);
126 }
127 
129 {
130  d->blur.destroy();
131 }
132 
133 bool Blur::isValid() const
134 {
135  return d->blur.isValid();
136 }
137 
138 void Blur::commit()
139 {
140  Q_ASSERT(isValid());
141  org_kde_kwin_blur_commit(d->blur);
142 }
143 
144 void Blur::setRegion(Region *region)
145 {
146  org_kde_kwin_blur_set_region(d->blur, *region);
147 }
148 
149 Blur::operator org_kde_kwin_blur *()
150 {
151  return d->blur;
152 }
153 
154 Blur::operator org_kde_kwin_blur *() const
155 {
156  return d->blur;
157 }
158 
159 }
160 }
BlurManager(QObject *parent=nullptr)
Creates a new BlurManager.
Definition: blur.cpp:28
Wrapper for the wl_surface interface.
Definition: surface.h:43
void destroy()
Destroys the data held by this Blur.
Definition: blur.cpp:128
void setup(org_kde_kwin_blur *blur)
Setup this Blur to manage the blur.
Definition: blur.cpp:121
bool isValid() const
Definition: blur.cpp:133
Wrapper for the org_kde_kwin_blur interface.
Definition: blur.h:132
Wrapper class for wl_event_queue interface.
Definition: event_queue.h:54
void setRegion(Region *region)
Sets the area of the window that will have a blurred background.
Definition: blur.cpp:144
void setup(org_kde_kwin_blur_manager *compositor)
Setup this BlurManager to manage the compositor.
Definition: blur.cpp:54
void release()
Releases the org_kde_kwin_blur interface.
Definition: blur.cpp:116
Blur * createBlur(Surface *surface, QObject *parent=nullptr)
Creates and setup a new Blur with parent.
Definition: blur.cpp:71
void destroy()
Destroys the data held by this BlurManager.
Definition: blur.cpp:44
void setEventQueue(EventQueue *queue)
Sets the queue to use for creating a Blur.
Definition: blur.cpp:61
EventQueue * eventQueue()
Definition: blur.cpp:66
void release()
Releases the org_kde_kwin_blur_manager interface.
Definition: blur.cpp:39
QObject * parent() const const
Wrapper for the wl_region interface.
Definition: region.h:31
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Jan 29 2023 03:54:07 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.