From 23784d2038e4a5d5a31185bf5948b686069ea60d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Thu, 19 Nov 2015 09:16:23 +0100 Subject: [PATCH] [wayland] Introduce an additional --exit-with-session command line arg This is similar to the applications to start. That is the value of the command line argument is interpreted as a command to start. The difference is that when this application exits, KWin will also quit. The argument is so to say interpreted as a session. Reviewed-By: Bhushan Shah --- main_wayland.cpp | 17 +++++++++++++++++ main_wayland.h | 4 ++++ 2 files changed, 21 insertions(+) diff --git a/main_wayland.cpp b/main_wayland.cpp index 9a15e99964..ca4262b14b 100644 --- a/main_wayland.cpp +++ b/main_wayland.cpp @@ -214,6 +214,14 @@ void ApplicationWayland::continueStartupWithX() } m_environment.insert(QStringLiteral("DISPLAY"), QString::fromUtf8(qgetenv("DISPLAY"))); + // start session + if (!m_sessionArgument.isEmpty()) { + QProcess *p = new QProcess(this); + p->setProcessEnvironment(m_environment); + auto finishedSignal = static_cast(&QProcess::finished); + connect(p, finishedSignal, this, &ApplicationWayland::quit); + p->start(m_sessionArgument); + } // start the applications passed to us as command line arguments if (!m_applicationsToStart.isEmpty()) { for (const QString &application: m_applicationsToStart) { @@ -513,6 +521,11 @@ int main(int argc, char * argv[]) i18n("Starts the session in locked mode.")); parser.addOption(screenLockerOption); + QCommandLineOption exitWithSessionOption(QStringLiteral("exit-with-session"), + i18n("Exit after the session application, which is started by KWin, closed."), + QStringLiteral("/path/to/session")); + parser.addOption(exitWithSessionOption); + parser.addPositionalArgument(QStringLiteral("applications"), i18n("Applications to start once Wayland and Xwayland server are started"), QStringLiteral("[/path/to/application...]")); @@ -527,6 +540,10 @@ int main(int argc, char * argv[]) return 0; } + if (parser.isSet(exitWithSessionOption)) { + a.setSessionArgument(parser.value(exitWithSessionOption)); + } + #if HAVE_INPUT KWin::Application::setUseLibinput(parser.isSet(libinputOption)); #endif diff --git a/main_wayland.h b/main_wayland.h index e5d7c962b4..c7f67410f5 100644 --- a/main_wayland.h +++ b/main_wayland.h @@ -46,6 +46,9 @@ public: void setProcessStartupEnvironment(const QProcessEnvironment &environment) { m_environment = environment; } + void setSessionArgument(const QString &session) { + m_sessionArgument = session; + } QProcessEnvironment processStartupEnvironment() const override { return m_environment; @@ -68,6 +71,7 @@ private: QProcess *m_xwaylandProcess = nullptr; QMetaObject::Connection m_xwaylandFailConnection; QProcessEnvironment m_environment; + QString m_sessionArgument; }; }