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 
18 namespace Client
19 {
20 
21 class Q_DECL_HIDDEN BlurManager::Private
22 {
23 public:
24  Private() = default;
25 
26  WaylandPointer<org_kde_kwin_blur_manager, org_kde_kwin_blur_manager_destroy> manager;
27  EventQueue *queue = nullptr;
28 };
29 
31  : QObject(parent)
32  , d(new Private)
33 {
34 }
35 
36 BlurManager::~BlurManager()
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 BlurManager::setup(org_kde_kwin_blur_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  Blur *s = new Blur(parent);
77  auto w = org_kde_kwin_blur_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 BlurManager::removeBlur(Surface *surface)
86 {
87  Q_ASSERT(isValid());
88  org_kde_kwin_blur_manager_unset(d->manager, *surface);
89 }
90 
91 BlurManager::operator org_kde_kwin_blur_manager*()
92 {
93  return d->manager;
94 }
95 
96 BlurManager::operator org_kde_kwin_blur_manager*() const
97 {
98  return d->manager;
99 }
100 
101 class Blur::Private
102 {
103 public:
104  WaylandPointer<org_kde_kwin_blur, org_kde_kwin_blur_release> blur;
105 };
106 
107 Blur::Blur(QObject *parent)
108  : QObject(parent)
109  , d(new Private)
110 {
111 }
112 
113 Blur::~Blur()
114 {
115  release();
116 }
117 
119 {
120  d->blur.release();
121 }
122 
123 void Blur::setup(org_kde_kwin_blur *blur)
124 {
125  Q_ASSERT(blur);
126  Q_ASSERT(!d->blur);
127  d->blur.setup(blur);
128 }
129 
131 {
132  d->blur.destroy();
133 }
134 
135 bool Blur::isValid() const
136 {
137  return d->blur.isValid();
138 }
139 
140 void Blur::commit()
141 {
142  Q_ASSERT(isValid());
143  org_kde_kwin_blur_commit(d->blur);
144 }
145 
146 void Blur::setRegion(Region *region)
147 {
148  org_kde_kwin_blur_set_region(d->blur, *region);
149 }
150 
151 Blur::operator org_kde_kwin_blur*()
152 {
153  return d->blur;
154 }
155 
156 Blur::operator org_kde_kwin_blur*() const
157 {
158  return d->blur;
159 }
160 
161 }
162 }
Wrapper for the org_kde_kwin_blur interface.
Definition: blur.h:135
BlurManager(QObject *parent=nullptr)
Creates a new BlurManager.
Definition: blur.cpp:30
void release()
Releases the org_kde_kwin_blur_manager interface.
Definition: blur.cpp:41
Wrapper class for wl_event_queue interface.
Definition: event_queue.h:55
void setRegion(Region *region)
Sets the area of the window that will have a blurred background.
Definition: blur.cpp:146
void setup(org_kde_kwin_blur *blur)
Setup this Blur to manage the blur.
Definition: blur.cpp:123
void release()
Releases the org_kde_kwin_blur interface.
Definition: blur.cpp:118
void setup(org_kde_kwin_blur_manager *compositor)
Setup this BlurManager to manage the compositor.
Definition: blur.cpp:56
Wrapper for the wl_surface interface.
Definition: surface.h:44
bool isValid() const
Definition: blur.cpp:135
void destroy()
Destroys the data held by this BlurManager.
Definition: blur.cpp:46
void destroy()
Destroys the data held by this Blur.
Definition: blur.cpp:130
QObject(QObject *parent)
Blur * createBlur(Surface *surface, QObject *parent=nullptr)
Creates and setup a new Blur with parent.
Definition: blur.cpp:73
void setEventQueue(EventQueue *queue)
Sets the queue to use for creating a Blur.
Definition: blur.cpp:63
EventQueue * eventQueue()
Definition: blur.cpp:68
QObject * parent() const const
bool isValid() const
Definition: blur.cpp:51
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 Thu Aug 13 2020 22:50:19 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.