Changeset View
Changeset View
Standalone View
Standalone View
effects/screenedge/screenedgeeffect.cpp
Show All 31 Lines | |||||
32 | #ifdef KWIN_HAVE_XRENDER_COMPOSITING | 32 | #ifdef KWIN_HAVE_XRENDER_COMPOSITING | ||
33 | #include <xcb/render.h> | 33 | #include <xcb/render.h> | ||
34 | #endif | 34 | #endif | ||
35 | 35 | | |||
36 | namespace KWin { | 36 | namespace KWin { | ||
37 | 37 | | |||
38 | ScreenEdgeEffect::ScreenEdgeEffect() | 38 | ScreenEdgeEffect::ScreenEdgeEffect() | ||
39 | : Effect() | 39 | : Effect() | ||
40 | , m_glow(new Plasma::Svg(this)) | | |||
41 | , m_cleanupTimer(new QTimer(this)) | 40 | , m_cleanupTimer(new QTimer(this)) | ||
42 | { | 41 | { | ||
43 | m_glow->setImagePath(QStringLiteral("widgets/glowbar")); | | |||
44 | connect(effects, SIGNAL(screenEdgeApproaching(ElectricBorder,qreal,QRect)), SLOT(edgeApproaching(ElectricBorder,qreal,QRect))); | 42 | connect(effects, SIGNAL(screenEdgeApproaching(ElectricBorder,qreal,QRect)), SLOT(edgeApproaching(ElectricBorder,qreal,QRect))); | ||
45 | m_cleanupTimer->setInterval(5000); | 43 | m_cleanupTimer->setInterval(5000); | ||
46 | m_cleanupTimer->setSingleShot(true); | 44 | m_cleanupTimer->setSingleShot(true); | ||
47 | connect(m_cleanupTimer, SIGNAL(timeout()), SLOT(cleanup())); | 45 | connect(m_cleanupTimer, SIGNAL(timeout()), SLOT(cleanup())); | ||
48 | connect(effects, &EffectsHandler::screenLockingChanged, this, | 46 | connect(effects, &EffectsHandler::screenLockingChanged, this, | ||
49 | [this] (bool locked) { | 47 | [this] (bool locked) { | ||
50 | if (locked) { | 48 | if (locked) { | ||
51 | cleanup(); | 49 | cleanup(); | ||
52 | } | 50 | } | ||
53 | } | 51 | } | ||
54 | ); | 52 | ); | ||
55 | } | 53 | } | ||
56 | 54 | | |||
57 | ScreenEdgeEffect::~ScreenEdgeEffect() | 55 | ScreenEdgeEffect::~ScreenEdgeEffect() | ||
58 | { | 56 | { | ||
59 | cleanup(); | 57 | cleanup(); | ||
60 | } | 58 | } | ||
61 | 59 | | |||
60 | void ScreenEdgeEffect::ensureGlowSvg() | ||||
61 | { | ||||
62 | if (!m_glow) { | ||||
63 | m_glow = new Plasma::Svg(this); | ||||
64 | m_glow->setImagePath(QStringLiteral("widgets/glowbar")); | ||||
65 | } | ||||
66 | } | ||||
67 | | ||||
62 | void ScreenEdgeEffect::cleanup() | 68 | void ScreenEdgeEffect::cleanup() | ||
63 | { | 69 | { | ||
64 | for (QHash<ElectricBorder, Glow*>::iterator it = m_borders.begin(); | 70 | for (QHash<ElectricBorder, Glow*>::iterator it = m_borders.begin(); | ||
65 | it != m_borders.end(); | 71 | it != m_borders.end(); | ||
66 | ++it) { | 72 | ++it) { | ||
67 | effects->addRepaint((*it)->geometry); | 73 | effects->addRepaint((*it)->geometry); | ||
68 | } | 74 | } | ||
69 | qDeleteAll(m_borders); | 75 | qDeleteAll(m_borders); | ||
▲ Show 20 Lines • Show All 188 Lines • ▼ Show 20 Line(s) | 251 | #endif | |||
258 | } | 264 | } | ||
259 | 265 | | |||
260 | return glow; | 266 | return glow; | ||
261 | } | 267 | } | ||
262 | 268 | | |||
263 | template <typename T> | 269 | template <typename T> | ||
264 | T *ScreenEdgeEffect::createCornerGlow(ElectricBorder border) | 270 | T *ScreenEdgeEffect::createCornerGlow(ElectricBorder border) | ||
265 | { | 271 | { | ||
272 | ensureGlowSvg(); | ||||
273 | | ||||
266 | switch (border) { | 274 | switch (border) { | ||
267 | case ElectricTopLeft: | 275 | case ElectricTopLeft: | ||
268 | return new T(m_glow->pixmap(QStringLiteral("bottomright")).toImage()); | 276 | return new T(m_glow->pixmap(QStringLiteral("bottomright")).toImage()); | ||
269 | case ElectricTopRight: | 277 | case ElectricTopRight: | ||
270 | return new T(m_glow->pixmap(QStringLiteral("bottomleft")).toImage()); | 278 | return new T(m_glow->pixmap(QStringLiteral("bottomleft")).toImage()); | ||
271 | case ElectricBottomRight: | 279 | case ElectricBottomRight: | ||
272 | return new T(m_glow->pixmap(QStringLiteral("topleft")).toImage()); | 280 | return new T(m_glow->pixmap(QStringLiteral("topleft")).toImage()); | ||
273 | case ElectricBottomLeft: | 281 | case ElectricBottomLeft: | ||
274 | return new T(m_glow->pixmap(QStringLiteral("topright")).toImage()); | 282 | return new T(m_glow->pixmap(QStringLiteral("topright")).toImage()); | ||
275 | default: | 283 | default: | ||
276 | return NULL; | 284 | return NULL; | ||
277 | } | 285 | } | ||
278 | } | 286 | } | ||
279 | 287 | | |||
280 | QSize ScreenEdgeEffect::cornerGlowSize(ElectricBorder border) const | 288 | QSize ScreenEdgeEffect::cornerGlowSize(ElectricBorder border) | ||
281 | { | 289 | { | ||
290 | ensureGlowSvg(); | ||||
291 | | ||||
282 | switch (border) { | 292 | switch (border) { | ||
283 | case ElectricTopLeft: | 293 | case ElectricTopLeft: | ||
284 | return m_glow->elementSize(QStringLiteral("bottomright")); | 294 | return m_glow->elementSize(QStringLiteral("bottomright")); | ||
285 | case ElectricTopRight: | 295 | case ElectricTopRight: | ||
286 | return m_glow->elementSize(QStringLiteral("bottomleft")); | 296 | return m_glow->elementSize(QStringLiteral("bottomleft")); | ||
287 | case ElectricBottomRight: | 297 | case ElectricBottomRight: | ||
288 | return m_glow->elementSize(QStringLiteral("topleft")); | 298 | return m_glow->elementSize(QStringLiteral("topleft")); | ||
289 | case ElectricBottomLeft: | 299 | case ElectricBottomLeft: | ||
290 | return m_glow->elementSize(QStringLiteral("topright")); | 300 | return m_glow->elementSize(QStringLiteral("topright")); | ||
291 | default: | 301 | default: | ||
292 | return QSize(); | 302 | return QSize(); | ||
293 | } | 303 | } | ||
294 | } | 304 | } | ||
295 | 305 | | |||
296 | template <typename T> | 306 | template <typename T> | ||
297 | T *ScreenEdgeEffect::createEdgeGlow(ElectricBorder border, const QSize &size) | 307 | T *ScreenEdgeEffect::createEdgeGlow(ElectricBorder border, const QSize &size) | ||
298 | { | 308 | { | ||
309 | ensureGlowSvg(); | ||||
310 | | ||||
299 | QPoint pixmapPosition(0, 0); | 311 | QPoint pixmapPosition(0, 0); | ||
300 | QPixmap l, r, c; | 312 | QPixmap l, r, c; | ||
301 | switch (border) { | 313 | switch (border) { | ||
302 | case ElectricTop: | 314 | case ElectricTop: | ||
303 | l = m_glow->pixmap(QStringLiteral("bottomleft")); | 315 | l = m_glow->pixmap(QStringLiteral("bottomleft")); | ||
304 | r = m_glow->pixmap(QStringLiteral("bottomright")); | 316 | r = m_glow->pixmap(QStringLiteral("bottomright")); | ||
305 | c = m_glow->pixmap(QStringLiteral("bottom")); | 317 | c = m_glow->pixmap(QStringLiteral("bottom")); | ||
306 | break; | 318 | break; | ||
▲ Show 20 Lines • Show All 43 Lines • Show Last 20 Lines |