lxqt-session/lxqt-session-0.11.1-add-poweroff.patch
Michael Vetter 7eb3c100e8 Accepting request 525862 from home:jubalh:lxqt-shutdown-bug
- boo#1044483:
  * Add lxqt-session-0.11.1-string-encoding.patch
    to have new string encoding
  * Add lxqt-session-0.11.1-add-poweroff.patch
    add option to power off

OBS-URL: https://build.opensuse.org/request/show/525862
OBS-URL: https://build.opensuse.org/package/show/X11:LXQt/lxqt-session?expand=0&rev=5
2017-09-13 13:38:43 +00:00

135 lines
4.3 KiB
Diff

From c0f743cf3185b85524ab8b99b1e9497c04ed2aa2 Mon Sep 17 00:00:00 2001
From: Palo Kisa <palo.kisa@gmail.com>
Date: Fri, 7 Jul 2017 09:00:22 +0200
Subject: [PATCH] lxqt-session: Provide reboot/powerOff methods
By providing the reboot/powerOff mehotds we are trying to terminate the
running processes/modules in prefered order (the logout procedure should
know how to do it). After that invoke the particular reboot/shutdown.
W/o the logout before reboot/shutdown the reboot/shutdown provider
(namely systemd) was terminating all proceses in undefined (random?)
order which could lead to insane shutdown and/or deadlocks with poorly
written applications/libraries.
---
lxqt-session/src/lxqtmodman.cpp | 5 +++--
lxqt-session/src/lxqtmodman.h | 2 +-
lxqt-session/src/sessionapplication.cpp | 2 +-
lxqt-session/src/sessiondbusadaptor.h | 31 +++++++++++++++++++++++++++++--
4 files changed, 34 insertions(+), 6 deletions(-)
diff --git a/lxqt-session/src/lxqtmodman.cpp b/lxqt-session/src/lxqtmodman.cpp
index 38f7548..2126296 100644
--- a/lxqt-session/src/lxqtmodman.cpp
+++ b/lxqt-session/src/lxqtmodman.cpp
@@ -347,7 +347,7 @@ LXQtModuleManager::~LXQtModuleManager()
/**
* @brief this logs us out by terminating our session
**/
-void LXQtModuleManager::logout()
+void LXQtModuleManager::logout(bool doExit)
{
// modules
ModulesMapIterator i(mNameMap);
@@ -377,7 +377,8 @@ void LXQtModuleManager::logout()
mWmProcess->kill();
}
- QCoreApplication::exit(0);
+ if (doExit)
+ QCoreApplication::exit(0);
}
QString LXQtModuleManager::showWmSelectDialog()
diff --git a/lxqt-session/src/lxqtmodman.h b/lxqt-session/src/lxqtmodman.h
index 1650cf3..69442ce 100644
--- a/lxqt-session/src/lxqtmodman.h
+++ b/lxqt-session/src/lxqtmodman.h
@@ -96,7 +96,7 @@ public slots:
gracefully (to kill it if it is not possible). Then the session
exits - it returns to the kdm/gdm in most cases.
*/
- void logout();
+ void logout(bool doExit);
signals:
void moduleStateChanged(QString moduleName, bool state);
diff --git a/lxqt-session/src/sessionapplication.cpp b/lxqt-session/src/sessionapplication.cpp
index 26637ed..a584993 100644
--- a/lxqt-session/src/sessionapplication.cpp
+++ b/lxqt-session/src/sessionapplication.cpp
@@ -61,7 +61,7 @@ SessionApplication::SessionApplication(int& argc, char** argv) :
qputenv("LXQT_SESSION_CONFIG", configName.toLocal8Bit());
modman = new LXQtModuleManager(winmanager);
- connect(this, &LXQt::Application::unixSignal, modman, &LXQtModuleManager::logout);
+ connect(this, &LXQt::Application::unixSignal, modman, [this] { modman->logout(true); });
new SessionDBusAdaptor(modman);
// connect to D-Bus and register as an object:
QDBusConnection::sessionBus().registerService("org.lxqt.session");
diff --git a/lxqt-session/src/sessiondbusadaptor.h b/lxqt-session/src/sessiondbusadaptor.h
index 283e6f0..ecb1f3f 100644
--- a/lxqt-session/src/sessiondbusadaptor.h
+++ b/lxqt-session/src/sessiondbusadaptor.h
@@ -29,6 +29,7 @@
#define SESSIONDBUS_H
#include <QtDBus>
+#include <LXQt/Power>
#include "lxqtmodman.h"
@@ -46,7 +47,8 @@ class SessionDBusAdaptor : public QDBusAbstractAdaptor
public:
SessionDBusAdaptor(LXQtModuleManager * manager)
: QDBusAbstractAdaptor(manager),
- m_manager(manager)
+ m_manager(manager),
+ m_power(false/*don't use ourself, just all other power providers*/)
{
connect(m_manager, SIGNAL(moduleStateChanged(QString,bool)), SIGNAL(moduleStateChanged(QString,bool)));
}
@@ -63,9 +65,33 @@ public slots:
return true;
}
+ bool canReboot()
+ {
+ return m_power.canReboot();
+ }
+
+ bool canPowerOff()
+ {
+ return m_power.canShutdown();
+ }
+
Q_NOREPLY void logout()
{
- m_manager->logout();
+ m_manager->logout(true);
+ }
+
+ Q_NOREPLY void reboot()
+ {
+ m_manager->logout(false);
+ m_power.reboot();
+ QCoreApplication::exit(0);
+ }
+
+ Q_NOREPLY void powerOff()
+ {
+ m_manager->logout(false);
+ m_power.shutdown();
+ QCoreApplication::exit(0);
}
QDBusVariant listModules()
@@ -85,6 +111,7 @@ public slots:
private:
LXQtModuleManager * m_manager;
+ LXQt::Power m_power;
};
#endif