[kde-workspace] more systemd_inhibit love (#859227, kde#307412)

Rex Dieter rdieter at fedoraproject.org
Tue Oct 30 12:39:16 UTC 2012


commit a5d32597fac22078e1c98b1074232da912e49de0
Author: Rex Dieter <rdieter at fedoraproject.org>
Date:   Tue Oct 30 07:39:11 2012 -0500

    more systemd_inhibit love (#859227, kde#307412)

 ... => kde-workspace-4.9.2-systemd_inhibit-2.patch |   18 +++-
 kde-workspace-4.9.2-systemd_inhibit-3.patch        |  124 ++++++++++++++++++++
 kde-workspace.spec                                 |   15 ++-
 3 files changed, 150 insertions(+), 7 deletions(-)
---
diff --git a/kde-workspace-4.9.2-systemd_inhibit.patch b/kde-workspace-4.9.2-systemd_inhibit-2.patch
similarity index 80%
rename from kde-workspace-4.9.2-systemd_inhibit.patch
rename to kde-workspace-4.9.2-systemd_inhibit-2.patch
index 8bf6011..e08d323 100644
--- a/kde-workspace-4.9.2-systemd_inhibit.patch
+++ b/kde-workspace-4.9.2-systemd_inhibit-2.patch
@@ -1,5 +1,16 @@
+commit a18b78d7da8cb8d627ad2e85f666bfcf1a2721e1
+Author: Lukas Tinkl <lukas at kde.org>
+Date:   Fri Oct 5 11:57:13 2012 +0200
+
+    store the filedescriptor in a member variable
+    
+    make systemd-inhibit work as intended, PowerDevil now handles
+    power/sleep/lid buttons as intended
+    
+    BUG: 307412
+
 diff --git a/powerdevil/daemon/powerdevilpolicyagent.cpp b/powerdevil/daemon/powerdevilpolicyagent.cpp
-index efc3476..acce121 100644
+index efc3476..70588db 100644
 --- a/powerdevil/daemon/powerdevilpolicyagent.cpp
 +++ b/powerdevil/daemon/powerdevilpolicyagent.cpp
 @@ -29,7 +29,6 @@
@@ -10,16 +21,17 @@ index efc3476..acce121 100644
  
  #include <KGlobal>
  #include <KDebug>
-@@ -225,6 +224,8 @@ void PolicyAgent::onSessionHandlerRegistered(const QString & serviceName)
+@@ -225,6 +224,9 @@ void PolicyAgent::onSessionHandlerRegistered(const QString & serviceName)
          onActiveSessionChanged(m_activeSessionPath);
  
          // inhibit systemd handling of power/sleep/lid buttons
++        // http://www.freedesktop.org/wiki/Software/systemd/inhibit
 +        kDebug() << "fd passing available:" << bool(managerIface.connection().connectionCapabilities() & QDBusConnection::UnixFileDescriptorPassing);
 +
          QVariantList args;
          args << "handle-power-key:handle-suspend-key:handle-hibernate-key:handle-lid-switch"; // what
          args << "PowerDevil"; // who
-@@ -232,8 +233,9 @@ void PolicyAgent::onSessionHandlerRegistered(const QString & serviceName)
+@@ -232,8 +234,9 @@ void PolicyAgent::onSessionHandlerRegistered(const QString & serviceName)
          args << "block"; // mode
          QDBusPendingReply<QDBusUnixFileDescriptor> desc = managerIface.asyncCallWithArgumentList("Inhibit", args);
          desc.waitForFinished();
diff --git a/kde-workspace-4.9.2-systemd_inhibit-3.patch b/kde-workspace-4.9.2-systemd_inhibit-3.patch
new file mode 100644
index 0000000..e36757f
--- /dev/null
+++ b/kde-workspace-4.9.2-systemd_inhibit-3.patch
@@ -0,0 +1,124 @@
+commit 80e9e6e48ff5b84962f3a8543ee06bcd4f122623
+Author: Lukáš Tinkl <lukas at kde.org>
+Date:   Tue Oct 30 11:32:52 2012 +0100
+
+    move systemd inhibition initialization to a slot
+    
+    and call it on resume. It looks like the filedescriptor
+    goes away when you suspend so we need to recreate it.
+    
+    BUG: 307412
+
+diff --git a/powerdevil/daemon/powerdevilcore.cpp b/powerdevil/daemon/powerdevilcore.cpp
+index df79667..7f24cbb 100644
+--- a/powerdevil/daemon/powerdevilcore.cpp
++++ b/powerdevil/daemon/powerdevilcore.cpp
+@@ -127,8 +127,6 @@ void Core::onBackendReady()
+             this, SLOT(onAcAdapterStateChanged(PowerDevil::BackendInterface::AcAdapterState)));
+     connect(m_backend, SIGNAL(batteryRemainingTimeChanged(qulonglong)),
+             this, SLOT(onBatteryRemainingTimeChanged(qulonglong)));
+-    connect(m_backend, SIGNAL(resumeFromSuspend()),
+-            this, SLOT(onResumeFromSuspend()));
+     connect(KIdleTime::instance(), SIGNAL(timeoutReached(int,int)),
+             this, SLOT(onKIdleTimeoutReached(int,int)));
+     connect(KIdleTime::instance(), SIGNAL(resumingFromIdle()),
+@@ -139,6 +137,9 @@ void Core::onBackendReady()
+     // Set up the policy agent
+     PowerDevil::PolicyAgent::instance()->init();
+ 
++    connect(m_backend, SIGNAL(resumeFromSuspend()),
++            this, SLOT(onResumeFromSuspend()));
++
+     // Initialize the action pool, which will also load the needed startup actions.
+     PowerDevil::ActionPool::instance()->init(this);
+ 
+@@ -601,6 +602,7 @@ void Core::onResumeFromSuspend()
+                                              "/ScreenSaver",
+                                              QDBusConnection::sessionBus());
+     iface.SimulateUserActivity();
++    PowerDevil::PolicyAgent::instance()->setupSystemdInhibition();
+ 
+     emit resumingFromSuspend();
+ }
+diff --git a/powerdevil/daemon/powerdevilpolicyagent.cpp b/powerdevil/daemon/powerdevilpolicyagent.cpp
+index 70588db..0777846 100644
+--- a/powerdevil/daemon/powerdevilpolicyagent.cpp
++++ b/powerdevil/daemon/powerdevilpolicyagent.cpp
+@@ -88,6 +88,7 @@ PolicyAgent *PolicyAgent::instance()
+ PolicyAgent::PolicyAgent(QObject* parent)
+     : QObject(parent)
+     , m_sdAvailable(false)
++    , m_systemdInhibitFd(-1)
+     , m_ckAvailable(false)
+     , m_sessionIsBeingInterrupted(false)
+     , m_lastCookie(0)
+@@ -223,23 +224,7 @@ void PolicyAgent::onSessionHandlerRegistered(const QString & serviceName)
+ 
+         onActiveSessionChanged(m_activeSessionPath);
+ 
+-        // inhibit systemd handling of power/sleep/lid buttons
+-        // http://www.freedesktop.org/wiki/Software/systemd/inhibit
+-        kDebug() << "fd passing available:" << bool(managerIface.connection().connectionCapabilities() & QDBusConnection::UnixFileDescriptorPassing);
+-
+-        QVariantList args;
+-        args << "handle-power-key:handle-suspend-key:handle-hibernate-key:handle-lid-switch"; // what
+-        args << "PowerDevil"; // who
+-        args << "KDE handles power events"; // why
+-        args << "block"; // mode
+-        QDBusPendingReply<QDBusUnixFileDescriptor> desc = managerIface.asyncCallWithArgumentList("Inhibit", args);
+-        desc.waitForFinished();
+-        if (desc.isValid()) {
+-            m_systemdInhibitFd = desc.value();
+-            kDebug() << "systemd powersave events handling inhibited, descriptor:" << m_systemdInhibitFd.fileDescriptor();
+-        }
+-        else
+-            kWarning() << "failed to inhibit systemd powersave handling";
++        setupSystemdInhibition();
+ 
+         kDebug() << "systemd support initialized";
+     } else if (serviceName == CONSOLEKIT_SERVICE) {
+@@ -552,6 +537,31 @@ void PolicyAgent::releaseAllInhibitions()
+     }
+ }
+ 
++void PolicyAgent::setupSystemdInhibition()
++{
++    if (m_systemdInhibitFd.fileDescriptor() != -1)
++        return;
++
++    // inhibit systemd handling of power/sleep/lid buttons
++    // http://www.freedesktop.org/wiki/Software/systemd/inhibit
++    QDBusInterface managerIface(SYSTEMD_LOGIN1_SERVICE, SYSTEMD_LOGIN1_PATH, SYSTEMD_LOGIN1_MANAGER_IFACE, QDBusConnection::systemBus());
++    kDebug() << "fd passing available:" << bool(managerIface.connection().connectionCapabilities() & QDBusConnection::UnixFileDescriptorPassing);
++
++    QVariantList args;
++    args << "handle-power-key:handle-suspend-key:handle-hibernate-key:handle-lid-switch"; // what
++    args << "PowerDevil"; // who
++    args << "KDE handles power events"; // why
++    args << "block"; // mode
++    QDBusPendingReply<QDBusUnixFileDescriptor> desc = managerIface.asyncCallWithArgumentList("Inhibit", args);
++    desc.waitForFinished();
++    if (desc.isValid()) {
++        m_systemdInhibitFd = desc.value();
++        kDebug() << "systemd powersave events handling inhibited, descriptor:" << m_systemdInhibitFd.fileDescriptor();
++    }
++    else
++        kWarning() << "failed to inhibit systemd powersave handling";
++}
++
+ }
+ 
+ #include "powerdevilpolicyagent.moc"
+diff --git a/powerdevil/daemon/powerdevilpolicyagent.h b/powerdevil/daemon/powerdevilpolicyagent.h
+index a046497..f1e8c03 100644
+--- a/powerdevil/daemon/powerdevilpolicyagent.h
++++ b/powerdevil/daemon/powerdevilpolicyagent.h
+@@ -74,6 +74,8 @@ public:
+ 
+     RequiredPolicies unavailablePolicies();
+ 
++    void setupSystemdInhibition();
++
+ public Q_SLOTS:
+     // Exported slots
+     uint AddInhibition(uint types, const QString &appName, const QString &reason);
diff --git a/kde-workspace.spec b/kde-workspace.spec
index c1d0489..38690b1 100644
--- a/kde-workspace.spec
+++ b/kde-workspace.spec
@@ -11,7 +11,7 @@
 Summary: KDE Workspace
 Name:    kde-workspace
 Version: 4.9.2
-Release: 7%{?dist}
+Release: 8%{?dist}
 
 License: GPLv2
 URL:     https://projects.kde.org/projects/kde/kde-workspace
@@ -125,8 +125,11 @@ Patch61: kde-workspace-r106793.patch
 Patch62: kde-workspace-r106794.patch
 
 ## upstream patches
-# systemd_inhibit work-in-progress
-Patch100: kde-workspace-4.9.2-systemd_inhibit.patch
+## systemd_inhibit work-in-progress
+# https://projects.kde.org/projects/kde/kde-workspace/repository/revisions/a18b78d7da8cb8d627ad2e85f666bfcf1a2721e1
+Patch102: kde-workspace-4.9.2-systemd_inhibit-2.patch
+# https://projects.kde.org/projects/kde/kde-workspace/repository/revisions/80e9e6e48ff5b84962f3a8543ee06bcd4f122623
+Patch103: kde-workspace-4.9.2-systemd_inhibit-3.patch
 
 ## plasma active patches
 # adapted version of wac-html-widgets.patch
@@ -467,7 +470,8 @@ Requires: akonadi
 %patch62 -p1 -b .r106794
 
 # upstream patches
-%patch100 -p1 -b .systemd_inhibit
+%patch102 -p1 -b .systemd_inhibit-2
+%patch103 -p1 -b .systemd_inhibit-3
 
 # plasma-active
 %patch153 -p1 -b .wac-html-widgets
@@ -1019,6 +1023,9 @@ fi
 
 
 %changelog
+* Tue Oct 30 2012 Rex Dieter <rdieter at fedoraproject.org> 4.9.2-8
+- more systemd_inhibit love (#859227, kde#307412)
+
 * Fri Oct 26 2012 Rex Dieter <rdieter at fedoraproject.org> 4.9.2-7
 - rework fontconfig patch to ensure $XDG_CONFIG_HOME/fontconfig exists
 


More information about the scm-commits mailing list