Changeset View
Changeset View
Standalone View
Standalone View
effects/backgroundcontrast/contrast.cpp
Show All 20 Lines | |||||
21 | 21 | | |||
22 | #include "contrast.h" | 22 | #include "contrast.h" | ||
23 | #include "contrastshader.h" | 23 | #include "contrastshader.h" | ||
24 | // KConfigSkeleton | 24 | // KConfigSkeleton | ||
25 | 25 | | |||
26 | #include <QMatrix4x4> | 26 | #include <QMatrix4x4> | ||
27 | #include <QWindow> | 27 | #include <QWindow> | ||
28 | 28 | | |||
29 | #include <KWayland/Server/surface_interface.h> | 29 | #include <KWaylandServer/surface_interface.h> | ||
30 | #include <KWayland/Server/contrast_interface.h> | 30 | #include <KWaylandServer/contrast_interface.h> | ||
31 | #include <KWayland/Server/display.h> | 31 | #include <KWaylandServer/display.h> | ||
32 | 32 | | |||
33 | namespace KWin | 33 | namespace KWin | ||
34 | { | 34 | { | ||
35 | 35 | | |||
36 | static const QByteArray s_contrastAtomName = QByteArrayLiteral("_KDE_NET_WM_BACKGROUND_CONTRAST_REGION"); | 36 | static const QByteArray s_contrastAtomName = QByteArrayLiteral("_KDE_NET_WM_BACKGROUND_CONTRAST_REGION"); | ||
37 | 37 | | |||
38 | ContrastEffect::ContrastEffect() | 38 | ContrastEffect::ContrastEffect() | ||
39 | { | 39 | { | ||
40 | shader = ContrastShader::create(); | 40 | shader = ContrastShader::create(); | ||
41 | 41 | | |||
42 | reconfigure(ReconfigureAll); | 42 | reconfigure(ReconfigureAll); | ||
43 | 43 | | |||
44 | // ### Hackish way to announce support. | 44 | // ### Hackish way to announce support. | ||
45 | // Should be included in _NET_SUPPORTED instead. | 45 | // Should be included in _NET_SUPPORTED instead. | ||
46 | if (shader && shader->isValid()) { | 46 | if (shader && shader->isValid()) { | ||
47 | net_wm_contrast_region = effects->announceSupportProperty(s_contrastAtomName, this); | 47 | net_wm_contrast_region = effects->announceSupportProperty(s_contrastAtomName, this); | ||
48 | KWayland::Server::Display *display = effects->waylandDisplay(); | 48 | KWaylandServer::Display *display = effects->waylandDisplay(); | ||
49 | if (display) { | 49 | if (display) { | ||
50 | m_contrastManager = display->createContrastManager(this); | 50 | m_contrastManager = display->createContrastManager(this); | ||
51 | m_contrastManager->create(); | 51 | m_contrastManager->create(); | ||
52 | } | 52 | } | ||
53 | } else { | 53 | } else { | ||
54 | net_wm_contrast_region = 0; | 54 | net_wm_contrast_region = 0; | ||
55 | } | 55 | } | ||
56 | 56 | | |||
▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Line(s) | 127 | for (unsigned int j = 0; j < 16; ++j) { | |||
128 | colorTransform[j] = floatCardinals[i + j]; | 128 | colorTransform[j] = floatCardinals[i + j]; | ||
129 | } | 129 | } | ||
130 | 130 | | |||
131 | QMatrix4x4 colorMatrix(colorTransform); | 131 | QMatrix4x4 colorMatrix(colorTransform); | ||
132 | m_colorMatrices[w] = colorMatrix; | 132 | m_colorMatrices[w] = colorMatrix; | ||
133 | } | 133 | } | ||
134 | } | 134 | } | ||
135 | 135 | | |||
136 | KWayland::Server::SurfaceInterface *surf = w->surface(); | 136 | KWaylandServer::SurfaceInterface *surf = w->surface(); | ||
137 | 137 | | |||
138 | if (surf && surf->contrast()) { | 138 | if (surf && surf->contrast()) { | ||
139 | region = surf->contrast()->region(); | 139 | region = surf->contrast()->region(); | ||
140 | m_colorMatrices[w] = colorMatrix(surf->contrast()->contrast(), surf->contrast()->intensity(), surf->contrast()->saturation()); | 140 | m_colorMatrices[w] = colorMatrix(surf->contrast()->contrast(), surf->contrast()->intensity(), surf->contrast()->saturation()); | ||
141 | } | 141 | } | ||
142 | 142 | | |||
143 | if (auto internal = w->internalWindow()) { | 143 | if (auto internal = w->internalWindow()) { | ||
144 | const auto property = internal->property("kwin_background_region"); | 144 | const auto property = internal->property("kwin_background_region"); | ||
Show All 24 Lines | 166 | if (region.isEmpty() && (!value.isNull() || (surf && surf->contrast()))) { | |||
169 | // being set, and being set to an empty region. | 169 | // being set, and being set to an empty region. | ||
170 | w->setData(WindowBackgroundContrastRole, 1); | 170 | w->setData(WindowBackgroundContrastRole, 1); | ||
171 | } else | 171 | } else | ||
172 | w->setData(WindowBackgroundContrastRole, region); | 172 | w->setData(WindowBackgroundContrastRole, region); | ||
173 | } | 173 | } | ||
174 | 174 | | |||
175 | void ContrastEffect::slotWindowAdded(EffectWindow *w) | 175 | void ContrastEffect::slotWindowAdded(EffectWindow *w) | ||
176 | { | 176 | { | ||
177 | KWayland::Server::SurfaceInterface *surf = w->surface(); | 177 | KWaylandServer::SurfaceInterface *surf = w->surface(); | ||
178 | 178 | | |||
179 | if (surf) { | 179 | if (surf) { | ||
180 | m_contrastChangedConnections[w] = connect(surf, &KWayland::Server::SurfaceInterface::contrastChanged, this, [this, w] () { | 180 | m_contrastChangedConnections[w] = connect(surf, &KWaylandServer::SurfaceInterface::contrastChanged, this, [this, w] () { | ||
181 | 181 | | |||
182 | if (w) { | 182 | if (w) { | ||
183 | updateContrastRegion(w); | 183 | updateContrastRegion(w); | ||
184 | } | 184 | } | ||
185 | }); | 185 | }); | ||
186 | } | 186 | } | ||
187 | 187 | | |||
188 | if (auto internal = w->internalWindow()) { | 188 | if (auto internal = w->internalWindow()) { | ||
▲ Show 20 Lines • Show All 341 Lines • Show Last 20 Lines |