Dominique Leuenberger 2017-09-13 20:38:15 +00:00 committed by Git OBS Bridge
commit e089ed2057
4 changed files with 200 additions and 0 deletions

View File

@ -0,0 +1,134 @@
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

View File

@ -0,0 +1,53 @@
From 4786793b55fa2d8b755faeb2c14f33a519d72c0f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lu=C3=ADs=20Pereira?= <luis.artur.pereira@gmail.com>
Date: Mon, 15 May 2017 19:38:29 +0100
Subject: [PATCH] String encoding (#103)
* Replace QString::toUtf8() with QString::toLatin1()
Udev subsystem strings are latin strings.
* Don't assume UTF-8 encoding.
QString::toLocal8Bit() uses QTextCodec::codecForLocale() is used to
perform the conversion.
---
lxqt-session/src/UdevNotifier.cpp | 2 +-
lxqt-session/src/sessionapplication.cpp | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/lxqt-session/src/UdevNotifier.cpp b/lxqt-session/src/UdevNotifier.cpp
index edcb8a6..3b87f87 100644
--- a/lxqt-session/src/UdevNotifier.cpp
+++ b/lxqt-session/src/UdevNotifier.cpp
@@ -52,7 +52,7 @@ UdevNotifier::UdevNotifier(QString const & subsystem, QObject * parent/* = nullp
return;
}
- int ret = udev_monitor_filter_add_match_subsystem_devtype(d->monitor, subsystem.toUtf8().constData(), nullptr);
+ int ret = udev_monitor_filter_add_match_subsystem_devtype(d->monitor, subsystem.toLatin1().constData(), nullptr);
if (0 != ret)
qCWarning(SESSION) << QStringLiteral("UdevNotifier: unable to add match subsystem, monitor will receive all devices");
diff --git a/lxqt-session/src/sessionapplication.cpp b/lxqt-session/src/sessionapplication.cpp
index cf6ed74..26637ed 100644
--- a/lxqt-session/src/sessionapplication.cpp
+++ b/lxqt-session/src/sessionapplication.cpp
@@ -58,7 +58,7 @@ SessionApplication::SessionApplication(int& argc, char** argv) :
configName = "session";
// tell the world which config file we're using.
- qputenv("LXQT_SESSION_CONFIG", configName.toUtf8());
+ qputenv("LXQT_SESSION_CONFIG", configName.toLocal8Bit());
modman = new LXQtModuleManager(winmanager);
connect(this, &LXQt::Application::unixSignal, modman, &LXQtModuleManager::logout);
@@ -135,7 +135,7 @@ void SessionApplication::loadEnvironmentSettings(LXQt::Settings& settings)
Q_FOREACH (QString i, settings.childKeys())
{
envVal = settings.value(i).toByteArray();
- lxqt_setenv(i.toUtf8().constData(), envVal);
+ lxqt_setenv(i.toLocal8Bit().constData(), envVal);
}
settings.endGroup();
}

View File

@ -1,3 +1,12 @@
-------------------------------------------------------------------
Wed Sep 13 12:34:35 UTC 2017 - mvetter@suse.com
- 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
-------------------------------------------------------------------
Fri Feb 24 01:38:49 UTC 2017 - sfalken@opensuse.org

View File

@ -26,6 +26,8 @@ Url: http://www.lxqt.org
Source0: http://downloads.lxqt.org/lxqt/%{version}/%{name}-%{version}.tar.xz
Source1: http://downloads.lxqt.org/lxqt/%{version}/%{name}-%{version}.tar.xz.asc
Source2: %{name}.keyring
Patch0: lxqt-session-0.11.1-string-encoding.patch
Patch1: lxqt-session-0.11.1-add-poweroff.patch
BuildRequires: cmake >= 3.0.2
BuildRequires: fdupes
BuildRequires: gcc-c++
@ -51,6 +53,8 @@ use when a user logs out and to restart them the next time the user logs in.
%prep
%setup -q
%patch0 -p1
%patch1 -p1
# Changing LXQt into X-LXQt in desktop files to be freedesktop compliant and shut rpmlint warnings
#find -name '*desktop.in*' -exec sed -ri 's/(LXQt;)/X-\1/' {} +