summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@centrum.cz>2017-03-22 11:18:52 (GMT)
committerLuboš Luňák <l.lunak@kde.org>2017-04-21 12:00:26 (GMT)
commit71908e79626b240d1c32ee88d726c227fa7d6a2d (patch)
treecc37e446233d3935637fa8bfef238f26ec817734
parent4421cc3041b9d172378ba5774241f7079f802073 (diff)
recognize the WM even if given with a full path
Normally kWin is launched simply as "kwin" ("kwin_x11", whatever), but in some cases it's restart command may be "/usr/bin/kwin", most notably when KWin restarts itself after a crash. Failing to recognize this client as the WM leads to KWin starting without any session management restoring. CCBUG: 377756
-rw-r--r--ksmserver/legacy.cpp2
-rw-r--r--ksmserver/server.cpp7
-rw-r--r--ksmserver/server.h2
-rw-r--r--ksmserver/startup.cpp4
4 files changed, 9 insertions, 6 deletions
diff --git a/ksmserver/legacy.cpp b/ksmserver/legacy.cpp
index 640b26e..336367d 100644
--- a/ksmserver/legacy.cpp
+++ b/ksmserver/legacy.cpp
@@ -258,7 +258,7 @@ void KSMServer::restoreLegacySession( KConfig* config )
int count = group.readEntry( "count", 0 );
for ( int i = 1; i <= count; i++ ) {
QString n = QString::number(i);
- if ( group.readEntry( QStringLiteral("program")+n, QString() ) != wm )
+ if ( !isWM( group.readEntry( QStringLiteral("program")+n, QString())))
continue;
QStringList restartCommand =
group.readEntry( QStringLiteral("restartCommand")+n, QStringList() );
diff --git a/ksmserver/server.cpp b/ksmserver/server.cpp
index 24c76c9..3701c3f 100644
--- a/ksmserver/server.cpp
+++ b/ksmserver/server.cpp
@@ -977,9 +977,12 @@ bool KSMServer::isWM( const KSMClient* client ) const
return isWM( client->program());
}
-bool KSMServer::isWM( const QString& command ) const
+bool KSMServer::isWM( const QString& program ) const
{
- return command == wm;
+ // Strip possible paths, so that even /usr/bin/kwin is recognized as kwin.
+ QString wmName = wm.mid( wm.lastIndexOf( QDir::separator()) + 1 );
+ QString programName = program.mid( program.lastIndexOf( QDir::separator()) + 1 );
+ return programName == wmName;
}
bool KSMServer::defaultSession() const
diff --git a/ksmserver/server.h b/ksmserver/server.h
index c3eb1cf..0549a5a 100644
--- a/ksmserver/server.h
+++ b/ksmserver/server.h
@@ -184,7 +184,7 @@ private:
void executeCommand( const QStringList& command );
bool isWM( const KSMClient* client ) const;
- bool isWM( const QString& command ) const;
+ bool isWM( const QString& program ) const;
void selectWm( const QString& kdewm );
bool defaultSession() const; // empty session
void setupXIOErrorHandler();
diff --git a/ksmserver/startup.cpp b/ksmserver/startup.cpp
index 8020bfb..2514e85 100644
--- a/ksmserver/startup.cpp
+++ b/ksmserver/startup.cpp
@@ -164,7 +164,7 @@ void KSMServer::restoreSession( const QString &sessionName )
if ( !wm.isEmpty() ) {
for ( int i = 1; i <= count; i++ ) {
QString n = QString::number(i);
- if ( wm == configSessionGroup.readEntry( QStringLiteral("program")+n, QString() ) ) {
+ if ( isWM( configSessionGroup.readEntry( QStringLiteral("program")+n, QString())) ) {
wmStartCommands << configSessionGroup.readEntry( QStringLiteral("restartCommand")+n, QStringList() );
}
}
@@ -365,7 +365,7 @@ void KSMServer::tryRestoreNext()
(config.readEntry( QStringLiteral("restartStyleHint")+n, 0 ) == SmRestartNever)) {
continue;
}
- if ( wm == config.readEntry( QStringLiteral("program")+n, QString() ) )
+ if ( isWM( config.readEntry( QStringLiteral("program")+n, QString())) )
continue; // wm already started
if( config.readEntry( QStringLiteral( "wasWm" )+n, false ))
continue; // it was wm before, but not now, don't run it (some have --replace in command :( )