Avoid unnecessary roundtrips finding out WM_CLIENT_MACHINE when setting

caption.

svn path=/trunk/kdebase/kwin/; revision=387096
This commit is contained in:
Luboš Luňák 2005-02-07 14:35:53 +00:00
parent a71d1d57dd
commit 240fc84c05
3 changed files with 15 additions and 16 deletions

View file

@ -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 ))

View file

@ -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;

View file

@ -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();