Do not try to set shadows for panels if theme does not provide elements

Summary:
Older Plasma themes, which are still offered also for current Plasma 5 e.g.
from store.kde.org, are missing out "shadow-*" elements for
"widgets/panel-background". The old code of the PanelShadows class does not
handle that case though, and as result for X11 sets a _KDE_NET_WM_SHADOW
property with "0" for most of the pixmaps due to them being an empty pixmap
in at least one dimension (except for the emtpy corner pixmap which is
always 1,1). The resulting behaviour with current KWin (X11) is this:
* when starting a Plasma shell with a theme without panel shadow elements,
  KWin does not show shadows
* when switching from a theme with shadow elements to one without, the
  shadow of the previous theme is continued to be used.
Reason is that KWin when parsing that property cancels the parsing when it
comes across a "0"/null id for a shadow pixmap, without further error
handling, so either does not create a shadow or keeps the old.

This patch catches the case of themes without any panel shadow elements and
only sets the _KDE_NET_WM_SHADOW property or wayland shadow if there are
shadows, otherwise removes them if needed.

Test Plan:
Switch between Plasma themes with and without separate shadow elements
defined (e.g. Breeze <-> Fluffy Bunny).

Reviewers: #plasma, mart

Reviewed By: #plasma, mart

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D20051
parent be4d60a4
......@@ -77,6 +77,7 @@ public:
void updateShadows();
void windowDestroyed(QObject *deletedObject);
void setupData(Plasma::FrameSvg::EnabledBorders enabledBorders);
bool hasShadows() const;
void setupWaylandIntegration();
......@@ -191,10 +192,19 @@ void PanelShadows::Private::windowDestroyed(QObject *deletedObject)
void PanelShadows::Private::updateShadows()
{
setupPixmaps();
QHash<const QWindow *, Plasma::FrameSvg::EnabledBorders>::const_iterator i;
for (i = m_windows.constBegin(); i != m_windows.constEnd(); ++i) {
updateShadow(i.key(), i.value());
// has shadows now?
if (hasShadows()) {
for (auto i = m_windows.constBegin(); i != m_windows.constEnd(); ++i) {
updateShadow(i.key(), i.value());
}
} else {
const bool hadShadowsBefore = !m_shadowPixmaps.isEmpty();
if (hadShadowsBefore) {
for (auto i = m_windows.constBegin(); i != m_windows.constEnd(); ++i) {
clearShadow(i.key());
}
clearPixmaps();
}
}
}
......@@ -508,6 +518,10 @@ void PanelShadows::Private::freeWaylandBuffers()
void PanelShadows::Private::updateShadow(const QWindow *window, Plasma::FrameSvg::EnabledBorders enabledBorders)
{
if (!hasShadows()) {
return;
}
#if HAVE_X11
if (m_isX11) {
updateShadowX11(window, enabledBorders);
......@@ -675,9 +689,9 @@ void PanelShadows::Private::clearShadowWayland(const QWindow *window)
surface->commit(KWayland::Client::Surface::CommitFlag::None);
}
bool PanelShadows::enabled() const
bool PanelShadows::Private::hasShadows() const
{
return hasElement(QStringLiteral("shadow-left"));
return q->hasElement(QStringLiteral("shadow-left"));
}
void PanelShadows::Private::setupWaylandIntegration()
......
......@@ -40,8 +40,6 @@ public:
void setEnabledBorders(const QWindow *window, Plasma::FrameSvg::EnabledBorders enabledBorders = Plasma::FrameSvg::AllBorders);
bool enabled() const;
private:
class Private;
Private * const d;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment