File login1-dbus-suspend.patch of Package psi+

logind sends a differnet signal during suspend, fix that by listening
on PrepareForSleep. But we need to wait on resuming case because it is
sent too early...

---
 src/libpsi/tools/systemwatch/systemwatch_unix.cpp |   10 ++++++++++
 src/libpsi/tools/systemwatch/systemwatch_unix.h   |    1 +
 2 files changed, 11 insertions(+)

--- a/src/libpsi/tools/systemwatch/systemwatch_unix.cpp
+++ b/src/libpsi/tools/systemwatch/systemwatch_unix.cpp
@@ -21,6 +21,7 @@
 #include "systemwatch_unix.h"
 #ifdef USE_DBUS
 # include <QDBusConnection>
+# include <QTimer>
 #endif
 
 UnixSystemWatch::UnixSystemWatch()
@@ -29,9 +30,18 @@ UnixSystemWatch::UnixSystemWatch()
 	QDBusConnection conn = QDBusConnection::systemBus();
 	conn.connect("org.freedesktop.UPower", "/org/freedesktop/UPower", "org.freedesktop.UPower", "Sleeping", this, SLOT(sleeping()));
 	conn.connect("org.freedesktop.UPower", "/org/freedesktop/UPower", "org.freedesktop.UPower", "Resuming", this, SLOT(resuming()));
+	conn.connect("org.freedesktop.login1", "/org/freedesktop/login1", "org.freedesktop.login1.Manager", "PrepareForSleep", this, SLOT(prepareForSleep(bool)));
 #endif
 }
 
+void UnixSystemWatch::prepareForSleep(bool suspending)
+{
+	if (suspending)
+		emit sleeping();
+	else
+		QTimer::singleShot(5000, this, SLOT(resuming()));
+}
+
 void UnixSystemWatch::sleeping()
 {
 	emit sleep();
--- a/src/libpsi/tools/systemwatch/systemwatch_unix.h
+++ b/src/libpsi/tools/systemwatch/systemwatch_unix.h
@@ -32,6 +32,7 @@ public:
 private slots:
 	void sleeping();
 	void resuming();
+	void prepareForSleep(bool suspending);
 };
 
 
openSUSE Build Service is sponsored by