[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
This commit is contained in:
Vlad Zagorodniy 2018-06-09 02:10:08 +03:00
parent d50f28033a
commit 7550d2a020

View file

@ -21,9 +21,19 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <kwinglutils.h>
#include <QSet>
namespace KWin
{
static const QSet<QString> 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;