diff --git a/activation.cpp b/activation.cpp index 2d1ffaa012..f9b6eac738 100644 --- a/activation.cpp +++ b/activation.cpp @@ -653,7 +653,8 @@ Time Client::readUserTimeMapTimestamp( const KStartupInfoData* asn_data, if( act->hasTransient( this, true )) ; // is transient for currently active window, even though it's not // the same app (e.g. kcookiejar dialog) -> allow activation - else if( groupTransient() && mainClients().isEmpty()) + else if( groupTransient() && + findClientInList( mainClients(), SameApplicationActiveHackPredicate( this )) == NULL ) ; // standalone transient else first_window = false; diff --git a/utils.h b/utils.h index fbfe4edbe0..914686c075 100644 --- a/utils.h +++ b/utils.h @@ -175,6 +175,17 @@ struct name \ KWIN_CHECK_PREDICATE( TruePredicate, cl == cl /*true, avoid warning about 'cl' */ ); +template< typename T > +Client* findClientInList( const ClientList& list, T predicate ) + { + for ( ClientList::ConstIterator it = list.begin(); it != list.end(); ++it) + { + if ( predicate( const_cast< const Client* >( *it))) + return *it; + } + return NULL; + } + inline int timestampCompare( Time time1, Time time2 ) // like strcmp() { diff --git a/workspace.h b/workspace.h index b4142d451f..f7eebe443c 100644 --- a/workspace.h +++ b/workspace.h @@ -631,16 +631,10 @@ inline bool Workspace::sessionSaving() const template< typename T > inline Client* Workspace::findClient( T predicate ) { - for ( ClientList::ConstIterator it = clients.begin(); it != clients.end(); ++it) - { - if ( predicate( const_cast< const Client* >( *it))) - return *it; - } - for ( ClientList::ConstIterator it = desktops.begin(); it != desktops.end(); ++it) - { - if ( predicate( const_cast< const Client* >( *it))) - return *it; - } + if( Client* ret = findClientInList( clients, predicate )) + return ret; + if( Client* ret = findClientInList( desktops, predicate )) + return ret; return NULL; }