From defa1061afe8583096d9e887dab3ce81fe1324bf Mon Sep 17 00:00:00 2001 From: Vlad Zagorodniy Date: Tue, 21 Aug 2018 13:43:16 +0300 Subject: [PATCH] [effects/diminactive] Fix initialization of m_activeWindow on reconfigure Summary: The Dim Inactive effect sees the world a little bit differently. m_activeWindow is currently active window that can be dimmed later on. In most cases, it's the same as effects->activeWindow(). In rare cases, it can be nullptr, even when effects->activeWindow() is not equal to nullptr (e.g. when active window is a context menu popup). canDimWindow is a helper that returns true if a given window should be dimmed, otherwise it returns false. It has one special case: if a given window is equal to m_activeWindow, return false. I.e. don't dim active windows. Currently, if user changes config of this effect, active window becomes dimmed. The reason for that is we hit that special case when deciding whether effects->activeWindow() should be m_activeWindow. This change addresses that problem by resetting m_activeWindow so we don't hit that special case. Test Plan: * Opened KCM of this effect; * Changed strength; * (the KCM window stayed bright after I clicked "Apply" button). (everything else works as expected) Reviewers: #kwin, davidedmundson Reviewed By: #kwin, davidedmundson Subscribers: kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D14973 --- effects/diminactive/diminactive.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/effects/diminactive/diminactive.cpp b/effects/diminactive/diminactive.cpp index 3e6754ce86..aae2c8b1b2 100644 --- a/effects/diminactive/diminactive.cpp +++ b/effects/diminactive/diminactive.cpp @@ -46,8 +46,6 @@ static inline bool belongToSameGroup(const EffectWindow *w1, const EffectWindow DimInactiveEffect::DimInactiveEffect() { - m_activeWindow = nullptr; - initConfig(); reconfigure(ReconfigureAll); @@ -78,6 +76,10 @@ void DimInactiveEffect::reconfigure(ReconfigureFlags flags) m_dimKeepAbove = DimInactiveConfig::dimKeepAbove(); m_dimByGroup = DimInactiveConfig::dimByGroup(); + // Need to reset m_activeWindow becase canDimWindow returns false + // if m_activeWindow is equal to effects->activeWindow(). + m_activeWindow = nullptr; + EffectWindow *activeWindow = effects->activeWindow(); m_activeWindow = (activeWindow && canDimWindow(activeWindow)) ? activeWindow