From 8a4fbd438abca04e6b6e54600b9759b82b8e9cb8 Mon Sep 17 00:00:00 2001 From: Philipp Knechtges Date: Thu, 12 Jan 2012 20:40:34 +0100 Subject: [PATCH] kwin: fixing high cpu usage in the fade effect This is a condensed version of Martin's patch that fixes a high cpu usage in KWin and X. It seems to be due to a window being created and deleted at almost the same time, such that the fade effect never quits. The bug was reliably reproducable with starting Amarok. CCBUG: 290025 CCBUG: 288948 --- effects/fade/fade.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/effects/fade/fade.cpp b/effects/fade/fade.cpp index 1a54eb0016..46ce1b3b53 100644 --- a/effects/fade/fade.cpp +++ b/effects/fade/fade.cpp @@ -169,12 +169,14 @@ void FadeEffect::slotWindowAdded(EffectWindow* w) void FadeEffect::slotWindowClosed(EffectWindow* w) { - if (!fadeWindows || !isFadeWindow(w)) + // In the cases, where we are still fading in or are not responsible, we do not fade out. + if (!fadeWindows || !isFadeWindow(w) || windows.contains(w)) { return; - if (!windows.contains(w)) - windows[ w ].opacity = w->opacity(); - if (windows[ w ].opacity == 1.0) + } + windows[ w ].opacity = w->opacity(); + if (windows[ w ].opacity == 1.0) { windows[ w ].opacity -= 0.1 / fadeOutTime; + } windows[ w ].deleted = true; w->refWindow(); w->addRepaintFull();