Changeset View
Changeset View
Standalone View
Standalone View
shell/panelshadows.cpp
Show First 20 Lines • Show All 71 Lines • ▼ Show 20 Line(s) | 52 | #endif | |||
---|---|---|---|---|---|
72 | void updateShadowX11(const QWindow *window, Plasma::FrameSvg::EnabledBorders); | 72 | void updateShadowX11(const QWindow *window, Plasma::FrameSvg::EnabledBorders); | ||
73 | void updateShadowWayland(const QWindow *window, Plasma::FrameSvg::EnabledBorders); | 73 | void updateShadowWayland(const QWindow *window, Plasma::FrameSvg::EnabledBorders); | ||
74 | void clearShadow(const QWindow *window); | 74 | void clearShadow(const QWindow *window); | ||
75 | void clearShadowX11(const QWindow *window); | 75 | void clearShadowX11(const QWindow *window); | ||
76 | void clearShadowWayland(const QWindow *window); | 76 | void clearShadowWayland(const QWindow *window); | ||
77 | void updateShadows(); | 77 | void updateShadows(); | ||
78 | void windowDestroyed(QObject *deletedObject); | 78 | void windowDestroyed(QObject *deletedObject); | ||
79 | void setupData(Plasma::FrameSvg::EnabledBorders enabledBorders); | 79 | void setupData(Plasma::FrameSvg::EnabledBorders enabledBorders); | ||
80 | bool hasShadows() const; | ||||
80 | 81 | | |||
81 | void setupWaylandIntegration(); | 82 | void setupWaylandIntegration(); | ||
82 | 83 | | |||
83 | PanelShadows *q; | 84 | PanelShadows *q; | ||
84 | QList<QPixmap> m_shadowPixmaps; | 85 | QList<QPixmap> m_shadowPixmaps; | ||
85 | 86 | | |||
86 | QPixmap m_emptyCornerPix; | 87 | QPixmap m_emptyCornerPix; | ||
87 | QPixmap m_emptyCornerLeftPix; | 88 | QPixmap m_emptyCornerLeftPix; | ||
▲ Show 20 Lines • Show All 98 Lines • ▼ Show 20 Line(s) | 185 | { | |||
186 | 187 | | |||
187 | if (m_windows.isEmpty()) { | 188 | if (m_windows.isEmpty()) { | ||
188 | clearPixmaps(); | 189 | clearPixmaps(); | ||
189 | } | 190 | } | ||
190 | } | 191 | } | ||
191 | 192 | | |||
192 | void PanelShadows::Private::updateShadows() | 193 | void PanelShadows::Private::updateShadows() | ||
193 | { | 194 | { | ||
194 | setupPixmaps(); | 195 | // has shadows now? | ||
195 | QHash<const QWindow *, Plasma::FrameSvg::EnabledBorders>::const_iterator i; | 196 | if (hasShadows()) { | ||
196 | for (i = m_windows.constBegin(); i != m_windows.constEnd(); ++i) { | 197 | for (auto i = m_windows.constBegin(); i != m_windows.constEnd(); ++i) { | ||
197 | updateShadow(i.key(), i.value()); | 198 | updateShadow(i.key(), i.value()); | ||
198 | } | 199 | } | ||
200 | } else { | ||||
201 | const bool hadShadowsBefore = !m_shadowPixmaps.isEmpty(); | ||||
202 | if (hadShadowsBefore) { | ||||
203 | for (auto i = m_windows.constBegin(); i != m_windows.constEnd(); ++i) { | ||||
204 | clearShadow(i.key()); | ||||
205 | } | ||||
206 | clearPixmaps(); | ||||
207 | } | ||||
208 | } | ||||
199 | } | 209 | } | ||
200 | 210 | | |||
201 | Qt::HANDLE PanelShadows::Private::createPixmap(const QPixmap& source) | 211 | Qt::HANDLE PanelShadows::Private::createPixmap(const QPixmap& source) | ||
202 | { | 212 | { | ||
203 | 213 | | |||
204 | // do nothing for invalid pixmaps | 214 | // do nothing for invalid pixmaps | ||
205 | if( source.isNull() ) return nullptr; | 215 | if( source.isNull() ) return nullptr; | ||
206 | 216 | | |||
▲ Show 20 Lines • Show All 296 Lines • ▼ Show 20 Line(s) | |||||
503 | 513 | | |||
504 | void PanelShadows::Private::freeWaylandBuffers() | 514 | void PanelShadows::Private::freeWaylandBuffers() | ||
505 | { | 515 | { | ||
506 | m_wayland.shadowBuffers.clear(); | 516 | m_wayland.shadowBuffers.clear(); | ||
507 | } | 517 | } | ||
508 | 518 | | |||
509 | void PanelShadows::Private::updateShadow(const QWindow *window, Plasma::FrameSvg::EnabledBorders enabledBorders) | 519 | void PanelShadows::Private::updateShadow(const QWindow *window, Plasma::FrameSvg::EnabledBorders enabledBorders) | ||
510 | { | 520 | { | ||
521 | if (!hasShadows()) { | ||||
522 | return; | ||||
523 | } | ||||
524 | | ||||
511 | #if HAVE_X11 | 525 | #if HAVE_X11 | ||
512 | if (m_isX11) { | 526 | if (m_isX11) { | ||
513 | updateShadowX11(window, enabledBorders); | 527 | updateShadowX11(window, enabledBorders); | ||
514 | } | 528 | } | ||
515 | #endif | 529 | #endif | ||
516 | if (m_wayland.manager) { | 530 | if (m_wayland.manager) { | ||
517 | updateShadowWayland(window, enabledBorders); | 531 | updateShadowWayland(window, enabledBorders); | ||
518 | } | 532 | } | ||
▲ Show 20 Lines • Show All 151 Lines • ▼ Show 20 Line(s) | 683 | { | |||
670 | KWayland::Client::Surface *surface = KWayland::Client::Surface::fromWindow(const_cast<QWindow*>(window)); | 684 | KWayland::Client::Surface *surface = KWayland::Client::Surface::fromWindow(const_cast<QWindow*>(window)); | ||
671 | if (!surface) { | 685 | if (!surface) { | ||
672 | return; | 686 | return; | ||
673 | } | 687 | } | ||
674 | m_wayland.manager->removeShadow(surface); | 688 | m_wayland.manager->removeShadow(surface); | ||
675 | surface->commit(KWayland::Client::Surface::CommitFlag::None); | 689 | surface->commit(KWayland::Client::Surface::CommitFlag::None); | ||
676 | } | 690 | } | ||
677 | 691 | | |||
678 | bool PanelShadows::enabled() const | 692 | bool PanelShadows::Private::hasShadows() const | ||
679 | { | 693 | { | ||
680 | return hasElement(QStringLiteral("shadow-left")); | 694 | return q->hasElement(QStringLiteral("shadow-left")); | ||
681 | } | 695 | } | ||
682 | 696 | | |||
683 | void PanelShadows::Private::setupWaylandIntegration() | 697 | void PanelShadows::Private::setupWaylandIntegration() | ||
684 | { | 698 | { | ||
685 | if (!KWindowSystem::isPlatformWayland()) { | 699 | if (!KWindowSystem::isPlatformWayland()) { | ||
686 | return; | 700 | return; | ||
687 | } | 701 | } | ||
688 | using namespace KWayland::Client; | 702 | using namespace KWayland::Client; | ||
Show All 24 Lines |