From 240fc84c05a35a5e46b7baacab87683285da4a52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Mon, 7 Feb 2005 14:35:53 +0000 Subject: [PATCH] Avoid unnecessary roundtrips finding out WM_CLIENT_MACHINE when setting caption. svn path=/trunk/kdebase/kwin/; revision=387096 --- client.cpp | 26 +++++++++++--------------- client.h | 2 ++ manage.cpp | 3 ++- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/client.cpp b/client.cpp index a5e14aa21c..c04850c130 100644 --- a/client.cpp +++ b/client.cpp @@ -1276,7 +1276,7 @@ void Client::setCaption( const QString& s, bool force ) cap_normal = s; bool was_suffix = ( !cap_suffix.isEmpty()); QString machine_suffix; - if( !isLocalMachine( wmClientMachine( false ))) + if( wmClientMachine( false ) != "localhost" && !isLocalMachine( wmClientMachine( false ))) machine_suffix = " <@" + wmClientMachine( true ) + ">"; cap_suffix = machine_suffix; if ( ( !isSpecialWindow() || isToolbar()) && workspace()->findClient( FetchNameInternalPredicate( this ))) @@ -1468,17 +1468,6 @@ QCString Client::staticWmCommand(WId w) return getStringProperty(w, XA_WM_COMMAND, ' '); } -/*! - Returns WM_CLIENT_MACHINE property for a given window. - */ -QCString Client::staticWmClientMachine(WId w) - { - QCString result = getStringProperty(w, XA_WM_CLIENT_MACHINE); - if (result.isEmpty()) - result = "localhost"; - return result; - } - /*! Returns WM_CLIENT_LEADER property for a given window. */ @@ -1534,15 +1523,22 @@ QCString Client::wmCommand() return result; } +void Client::getWmClientMachine() + { + client_machine = getStringProperty(window(), XA_WM_CLIENT_MACHINE); + if( client_machine.isEmpty() && wmClientLeaderWin && wmClientLeaderWin!=window()) + client_machine = getStringProperty(wmClientLeaderWin, XA_WM_CLIENT_MACHINE); + if( client_machine.isEmpty()) + client_machine = "localhost"; + } + /*! Returns client machine for this client, taken either from its window or from the leader window. */ QCString Client::wmClientMachine( bool use_localhost ) const { - QCString result = staticWmClientMachine(window()); - if (result.isEmpty() && wmClientLeaderWin && wmClientLeaderWin!=window()) - result = staticWmClientMachine(wmClientLeaderWin); + QCString result = client_machine; if( use_localhost ) { // special name for the local machine (localhost) if( result != "localhost" && isLocalMachine( result )) diff --git a/client.h b/client.h index 2c368abde0..e7f5daeb28 100644 --- a/client.h +++ b/client.h @@ -358,6 +358,7 @@ class Client : public QObject, public KDecorationDefines void getMotifHints(); void getIcons(); void getWmClientLeader(); + void getWmClientMachine(); void fetchName(); void fetchIconicName(); QString readName() const; @@ -498,6 +499,7 @@ class Client : public QObject, public KDecorationDefines Colormap cmap; QCString resource_name; QCString resource_class; + QCString client_machine; QString cap_normal, cap_iconic, cap_suffix; WId wmClientLeaderWin; QCString window_role; diff --git a/manage.cpp b/manage.cpp index 592f0fc649..15ef469233 100644 --- a/manage.cpp +++ b/manage.cpp @@ -93,6 +93,8 @@ bool Client::manage( Window w, bool isMapped ) ignore_focus_stealing = options->checkIgnoreFocusStealing( this ); // TODO change to rules window_role = staticWindowRole( w ); + getWmClientLeader(); + getWmClientMachine(); // first only read the caption text, so that setupWindowRules() can use it for matching, // and only then really set the caption using setCaption(), which checks for duplicates etc. // and also relies on rules already existing @@ -103,7 +105,6 @@ bool Client::manage( Window w, bool isMapped ) detectNoBorder(); fetchIconicName(); getWMHints(); // needs to be done before readTransient() because of reading the group - getWmClientLeader(); // needs to be done before readTransient() because of same app comparing modal = ( info->state() & NET::Modal ) != 0; // needs to be valid before handling groups readTransient(); getIcons();