summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2016-03-16 22:47:37 +0100
committerAndy Wingo <wingo@pobox.com>2016-03-16 22:47:37 +0100
commit880c6a277e6a1099dff0015330cec1cd79a1d36e (patch)
treefe45f3e31de49835397011d5cfd07daf19e70de7
parent6ea7bda00bf8747a35b8e134f40463589b2fe4b2 (diff)
Emit PrepareForSleep when resuming.
-rw-r--r--src/login/logind-dbus.c47
1 files changed, 25 insertions, 22 deletions
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
index 6f7e5692aa..210e754809 100644
--- a/src/login/logind-dbus.c
+++ b/src/login/logind-dbus.c
@@ -1417,6 +1417,28 @@ int manager_set_lid_switch_ignore(Manager *m, usec_t until) {
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,
@@ -1434,6 +1456,9 @@ static int execute_shutdown_or_sleep(
if (r < 0)
return r;
+ /* And we're back. */
+ send_prepare_for(m, w, false);
+
/* Make sure the lid switch is ignored for a while (?) */
manager_set_lid_switch_ignore(m, now(CLOCK_MONOTONIC) + m->holdoff_timeout_usec);
@@ -1456,28 +1481,6 @@ static int delay_shutdown_or_sleep(
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,