chiark / gitweb /
Emit PrepareForSleep when resuming and clear pending action after resume from delayed...
authorSven Eden <yamakuzure@gmx.net>
Fri, 10 Feb 2017 13:14:29 +0000 (14:14 +0100)
committerSven Eden <yamakuzure@gmx.net>
Tue, 14 Mar 2017 09:23:13 +0000 (10:23 +0100)
src/login/logind-dbus.c

index ede92822db689f7e82bff1f24fa7a517c9916c11..bf00b137a31f4cdd278aed227c982e6498369d3b 100644 (file)
@@ -1436,6 +1436,28 @@ int manager_set_lid_switch_ignore(Manager *m, usec_t until) {
         return r;
 }
 
         return r;
 }
 
+static int send_prepare_for(Manager *m, InhibitWhat w, bool _active) {
+
+        static const char * const signal_name[_INHIBIT_WHAT_MAX] = {
+                [INHIBIT_SHUTDOWN] = "PrepareForShutdown",
+                [INHIBIT_SLEEP] = "PrepareForSleep"
+        };
+
+        int active = _active;
+
+        assert(m);
+        assert(w >= 0);
+        assert(w < _INHIBIT_WHAT_MAX);
+        assert(signal_name[w]);
+
+        return sd_bus_emit_signal(m->bus,
+                                  "/org/freedesktop/login1",
+                                  "org.freedesktop.login1.Manager",
+                                  signal_name[w],
+                                  "b",
+                                  active);
+}
+
 static int execute_shutdown_or_sleep(
                 Manager *m,
                 InhibitWhat w,
 static int execute_shutdown_or_sleep(
                 Manager *m,
                 InhibitWhat w,
@@ -1489,6 +1511,12 @@ static int execute_shutdown_or_sleep(
         m->action_what = w;
 #endif // 0
 
         m->action_what = w;
 #endif // 0
 
+        if (w == INHIBIT_SLEEP)
+                /* And we're back. */
+                send_prepare_for(m, w, false);
+
+        m->action_what = 0;
+
         /* Make sure the lid switch is ignored for a while */
         manager_set_lid_switch_ignore(m, now(CLOCK_MONOTONIC) + m->holdoff_timeout_usec);
 
         /* Make sure the lid switch is ignored for a while */
         manager_set_lid_switch_ignore(m, now(CLOCK_MONOTONIC) + m->holdoff_timeout_usec);
 
@@ -1569,28 +1597,6 @@ static int delay_shutdown_or_sleep(
         return 0;
 }
 
         return 0;
 }
 
-static int send_prepare_for(Manager *m, InhibitWhat w, bool _active) {
-
-        static const char * const signal_name[_INHIBIT_WHAT_MAX] = {
-                [INHIBIT_SHUTDOWN] = "PrepareForShutdown",
-                [INHIBIT_SLEEP] = "PrepareForSleep"
-        };
-
-        int active = _active;
-
-        assert(m);
-        assert(w >= 0);
-        assert(w < _INHIBIT_WHAT_MAX);
-        assert(signal_name[w]);
-
-        return sd_bus_emit_signal(m->bus,
-                                  "/org/freedesktop/login1",
-                                  "org.freedesktop.login1.Manager",
-                                  signal_name[w],
-                                  "b",
-                                  active);
-}
-
 int bus_manager_shutdown_or_sleep_now_or_later(
                 Manager *m,
                 HandleAction action,
 int bus_manager_shutdown_or_sleep_now_or_later(
                 Manager *m,
                 HandleAction action,