diff --git a/client.cpp b/client.cpp index 8a9ef523fa..85b6dbec9b 100644 --- a/client.cpp +++ b/client.cpp @@ -410,7 +410,18 @@ void Client::fetchName() if ( XFetchName( qt_xdisplay(), win, &name ) && name ) { QString s = QString::fromLatin1( name ); if ( s != caption() ) { - setCaption( QString::fromLatin1( name ) ); + setCaption( "" ); + if (workspace()->hasCaption( s ) ){ + int i = 2; + QString s2; + do { + s2 = s + " <" + QString::number(i) + ">"; + i++; + } while (workspace()->hasCaption(s2) ); + s = s2; + } + setCaption( s ); + if ( !isWithdrawn() ) captionChange( caption() ); } diff --git a/workspace.cpp b/workspace.cpp index 94665b54f3..d65bff9f9e 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -775,6 +775,19 @@ void Workspace::iconifyOrDeiconifyTransientsOf( Client* c ) } +/*! + Returns whether a client with the specified \a caption exists, or not. + */ +bool Workspace::hasCaption( const QString& caption ) +{ + for ( ClientList::ConstIterator it = clients.begin(); it != clients.end(); ++it) { + if ( (*it)->caption() == caption ) + return TRUE; + } + return FALSE; +} + + /*! Tries to activate the client by asking X for the input focus. This function does not perform any show, raise or desktop switching. See diff --git a/workspace.h b/workspace.h index d6ab2822cb..8ff86ee0b1 100644 --- a/workspace.h +++ b/workspace.h @@ -99,6 +99,8 @@ public: bool iconifyMeansWithdraw( Client* ); void iconifyOrDeiconifyTransientsOf( Client* ); + + bool hasCaption( const QString& caption ); public slots: void setCurrentDesktop( int new_desktop );