[effects/dimscreen] Make it work on Wayland

Summary:
There is no concept of managed windows in Wayland, so every time we call
managed() on a Wayland client, it will return false. We need to call
that method only for X11 clients.

The resource name part for authentication agents is empty because
KWayland can't get their executable paths.

CCBUG: 398100

Test Plan:
Before:
{F6338545}

After:
{F6338546}

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: davidedmundson, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16317
This commit is contained in:
Vlad Zagorodniy 2018-10-19 14:43:58 +03:00
parent 9f3a447a43
commit 4e545f5594

View file

@ -32,6 +32,11 @@ static const QSet<QString> s_authWindows {
QStringLiteral("pinentry pinentry"),
QStringLiteral("polkit-kde-authentication-agent-1 polkit-kde-authentication-agent-1"),
QStringLiteral("polkit-kde-manager polkit-kde-manager"),
// On Wayland, the resource name is filename of executable. It's empty for
// authentication agents because KWayland can't get their executable paths.
QStringLiteral(" org.kde.kdesu"),
QStringLiteral(" org.kde.polkit-kde-authentication-agent-1")
};
DimScreenEffect::DimScreenEffect()
@ -84,9 +89,22 @@ void DimScreenEffect::postPaintScreen()
effects->postPaintScreen();
}
static inline bool isDimWindow(const EffectWindow *w)
{
if (w->isPopupWindow()) {
return false;
}
if (w->isX11Client() && !w->isManaged()) {
return false;
}
return true;
}
void DimScreenEffect::paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data)
{
if (mActivated && (w != window) && w->isManaged()) {
if (mActivated && (w != window) && isDimWindow(w)) {
data.multiplyBrightness((1.0 - 0.33 * timeline.currentValue()));
data.multiplySaturation((1.0 - 0.33 * timeline.currentValue()));
}