From 6e6afed817a660b3237138b5d1daf587d643d9e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Mon, 9 Jun 2008 15:46:57 +0000 Subject: [PATCH] Don't rearrange windows if only filtering removed some of them, so that they don't possibly jump to the freed positions. svn path=/trunk/KDE/kdebase/workspace/; revision=818778 --- effects/presentwindows.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/effects/presentwindows.cpp b/effects/presentwindows.cpp index 099a254dee..b7cae7e3f7 100644 --- a/effects/presentwindows.cpp +++ b/effects/presentwindows.cpp @@ -387,17 +387,24 @@ void PresentWindowsEffect::rearrangeWindows() { bool rearrange = canRearrangeClosest( windowlist ); // called before manipulating mWindowData DataHash newdata; - EffectWindowList newlist = windowlist; - EffectWindowList oldlist = mWindowData.keys(); - qSort( newlist ); - qSort( oldlist ); + int oldcount = mWindowData.count(); for( DataHash::ConstIterator it = mWindowData.begin(); it != mWindowData.end(); ++it ) if( windowlist.contains( it.key())) // remove windows that are not in the window list newdata[ it.key() ] = *it; mWindowData = newdata; - if( !rearrange && newlist == oldlist ) + // Initialize new entries + foreach( EffectWindow* w, windowlist ) + if( !mWindowData.contains( w )) + { + mWindowData[ w ].highlight = 0; + } + // Do not rearrange if filtering only removed windows, so that the remaining ones don't possibly + // jump into the freed slots if they'd be a better match. + // This can probably still lead to such things when removing the filter again, but that'd need + // more complex remembering of window positions. + if( !rearrange && oldcount >= mWindowData.count()) return; if( mHighlightedWindow != NULL && !mWindowData.contains( mHighlightedWindow )) setHighlightedWindow( NULL ); @@ -408,12 +415,6 @@ void PresentWindowsEffect::rearrangeWindows() (*it).old_area = (*it).area; (*it).old_scale = (*it).scale; } - // Initialize new entries - foreach( EffectWindow* w, windowlist ) - if( !mWindowData.contains( w )) - { - mWindowData[ w ].highlight = 0; - } mRearranging = 0; // start animation again }