From 16384499970fa2c838cbc042c7a338b030348cab Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Sat, 6 Oct 2018 16:28:46 +0300 Subject: [PATCH] imrove windowChanged signal under X11 --the new code contains more comments and except blacklisting all NET::Properties2 signals that are not accompanied with NET::Properties it also whitelists specific states for NET::WMState. This should lower a lot the calculations needed in order to support the dodge visibility modes. At the same time apps that are abusing X11 signals should be ignored totally because the whitelisted states and NET::Properties are only set by the user or the window manager. BUG: 399149 FIXED-IN: 0.8.2 --- app/xwindowinterface.cpp | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/app/xwindowinterface.cpp b/app/xwindowinterface.cpp index 40ab36148..39bfcf0b3 100644 --- a/app/xwindowinterface.cpp +++ b/app/xwindowinterface.cpp @@ -348,20 +348,40 @@ void XWindowInterface::windowChangedProxy(WId wid, NET::Properties prop1, NET::P const auto winType = KWindowInfo(wid, NET::WMWindowType).windowType(NET::DesktopMask); + //! update desktop id if (winType != -1 && (winType & NET::Desktop)) { m_desktopId = wid; emit windowChanged(wid); return; } - //! ignore when, eg: the user presses a key, or a window is sending X events + //! accept only NET::Properties events, + //! ignore when the user presses a key, or a window is sending X events etc. //! without needing to (e.g. Firefox, https://bugzilla.mozilla.org/show_bug.cgi?id=1389953) - if (prop1 == 0 && (prop2 == NET::WM2UserTime || prop2 == NET::WM2IconPixmap)) { + //! NET::WM2UserTime, NET::WM2IconPixmap etc.... + if (prop1 == 0) { return; } - if (prop1 && !(prop1 & NET::WMState || prop1 & NET::WMGeometry || prop1 & NET::ActiveWindow)) + //! accepty only the following NET:Properties changed signals + //! NET::WMState, NET::WMGeometry, NET::ActiveWindow + if (!((prop1 & NET::WMState) || (prop1 & NET::WMGeometry) || (prop1 & NET::ActiveWindow))) { return; + } + + //! when only WMState changed we can whitelist the acceptable states + if ((prop1 & NET::WMState) && !(prop1 & NET::WMGeometry) && !(prop1 & NET::ActiveWindow)) { + KWindowInfo info(wid, NET::WMState); + + if (info.valid()) { + if (!info.hasState(NET::Sticky) && !info.hasState(NET::Shaded) + && !info.hasState(NET::FullScreen) && !info.hasState(NET::Hidden)) { + return; + } + } else { + return; + } + } emit windowChanged(wid); }