From 47075ef04ebc250a76a5eeafdeabc737f4bbee5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Mon, 28 Feb 2005 13:43:00 +0000 Subject: [PATCH] Break unnecessary transiency relations caused by many group transient windows. Avoids exponentially expensive operations in KWin. CCBUG: 95231 svn path=/trunk/kdebase/kwin/; revision=393793 --- group.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/group.cpp b/group.cpp index a01b32de58..df11b7542d 100644 --- a/group.cpp +++ b/group.cpp @@ -541,6 +541,25 @@ void Client::checkGroupTransients() // TODO This could possibly be optimized, it also requires hasTransient() to check for loops. if( (*it2)->groupTransient() && (*it1)->hasTransient( *it2, true ) && (*it2)->hasTransient( *it1, true )) (*it2)->transients_list.remove( *it1 ); + // if there are already windows W1 and W2, W2 being transient for W1, and group transient W3 + // is added, make it transient only for W2, not for W1, because it's already indirectly + // transient for it - the indirect transiency actually shouldn't break anything, + // but it can lead to exponentially expensive operations (#95231) + // TODO this is pretty slow as well + for( ClientList::ConstIterator it3 = group()->members().begin(); + it3 != group()->members().end(); + ++it3 ) + { + if( *it1 == *it2 || *it2 == *it3 || *it1 == *it3 ) + continue; + if( (*it2)->hasTransient( *it1, false ) && (*it3)->hasTransient( *it1, false )) + { + if( (*it2)->hasTransient( *it3, true )) + (*it3)->transients_list.remove( *it1 ); + if( (*it3)->hasTransient( *it2, true )) + (*it2)->transients_list.remove( *it1 ); + } + } } } }