From 7550d2a02064e7e524945a659b8499ed7a9dc0d6 Mon Sep 17 00:00:00 2001 From: Vlad Zagorodniy Date: Sat, 9 Jun 2018 02:10:08 +0300 Subject: [PATCH] [effects/dimscreen] Use QSet for checking whether activated window asks for permissions Summary: Do not construct QStringList with classes of windows that ask for permissions. Instead, create a static set of those window classes (to avoid the unnecessary construction of QStringList and make lookups faster). Reviewers: #kwin, davidedmundson Reviewed By: #kwin, davidedmundson Subscribers: kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D13440 --- effects/dimscreen/dimscreen.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/effects/dimscreen/dimscreen.cpp b/effects/dimscreen/dimscreen.cpp index 3b6147c1bb..a7f4f7e4d7 100644 --- a/effects/dimscreen/dimscreen.cpp +++ b/effects/dimscreen/dimscreen.cpp @@ -21,9 +21,19 @@ along with this program. If not, see . #include +#include + namespace KWin { +static const QSet s_authWindows { + QStringLiteral("kdesu kdesu"), + QStringLiteral("kdesudo kdesudo"), + QStringLiteral("pinentry pinentry"), + QStringLiteral("polkit-kde-authentication-agent-1 polkit-kde-authentication-agent-1"), + QStringLiteral("polkit-kde-manager polkit-kde-manager"), +}; + DimScreenEffect::DimScreenEffect() : mActivated(false) , activateAnimation(false) @@ -86,13 +96,7 @@ void DimScreenEffect::paintWindow(EffectWindow *w, int mask, QRegion region, Win void DimScreenEffect::slotWindowActivated(EffectWindow *w) { if (!w) return; - QStringList check; - check << QStringLiteral("kdesu kdesu"); - check << QStringLiteral("kdesudo kdesudo"); - check << QStringLiteral("polkit-kde-manager polkit-kde-manager"); - check << QStringLiteral("polkit-kde-authentication-agent-1 polkit-kde-authentication-agent-1"); - check << QStringLiteral("pinentry pinentry"); - if (check.contains(w->windowClass())) { + if (s_authWindows.contains(w->windowClass())) { mActivated = true; activateAnimation = true; deactivateAnimation = false;