summaryrefslogtreecommitdiff
path: root/src/gs-monitor.c
diff options
context:
space:
mode:
authorAli Akbar <[email protected]>2019-08-26 20:31:54 +0700
committermonsta <[email protected]>2019-08-26 16:31:54 +0300
commit234e5c835559b0afe56c2af246e2148ac5b47a07 (patch)
tree51d6321e673bde892596c028b42cec4ce9714db1 /src/gs-monitor.c
parent2ce29e42f9ad5b5b618fb726e264b850f59cbebc (diff)
downloadmate-screensaver-234e5c835559b0afe56c2af246e2148ac5b47a07.tar.bz2
mate-screensaver-234e5c835559b0afe56c2af246e2148ac5b47a07.tar.xz
Ensure lock on suspend and unlock on resume
This patch is adopted from xfce4-screensaver: https://git.xfce.org/apps/xfce4-screensaver/commit/?id=9e53bb2866 Modified to match screen locking behavior of mate-power-manager. Introduced new Inhibitor lock to make sure lock was in place and user will be greeted with unlock dialog when resumes from suspend/ hibernate.
Diffstat (limited to 'src/gs-monitor.c')
-rw-r--r--src/gs-monitor.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/gs-monitor.c b/src/gs-monitor.c
index 732a59b..1601d75 100644
--- a/src/gs-monitor.c
+++ b/src/gs-monitor.c
@@ -280,6 +280,17 @@ static void listener_simulate_user_activity_cb(GSListener* listener, GSMonitor*
gs_monitor_simulate_user_activity(monitor);
}
+static void listener_prepare_for_sleep_cb(GSListener* listener, gboolean prepare, GSMonitor* monitor)
+{
+ gboolean locked;
+
+ gs_manager_get_lock_active(monitor->priv->manager, &locked);
+ if (locked) {
+ /* show unlock dialog */
+ gs_manager_show_message(monitor->priv->manager, NULL, NULL, NULL);
+ }
+}
+
static void _gs_monitor_update_from_prefs(GSMonitor* monitor, GSPrefs* prefs)
{
gboolean idle_detection_enabled;
@@ -347,6 +358,7 @@ static void disconnect_listener_signals(GSMonitor* monitor)
g_signal_handlers_disconnect_by_func(monitor->priv->listener, listener_throttle_changed_cb, monitor);
g_signal_handlers_disconnect_by_func(monitor->priv->listener, listener_simulate_user_activity_cb, monitor);
g_signal_handlers_disconnect_by_func(monitor->priv->listener, listener_show_message_cb, monitor);
+ g_signal_handlers_disconnect_by_func(monitor->priv->listener, listener_prepare_for_sleep_cb, monitor);
}
static void connect_listener_signals(GSMonitor* monitor)
@@ -358,6 +370,7 @@ static void connect_listener_signals(GSMonitor* monitor)
g_signal_connect(monitor->priv->listener, "throttle-changed", G_CALLBACK(listener_throttle_changed_cb), monitor);
g_signal_connect(monitor->priv->listener, "simulate-user-activity", G_CALLBACK(listener_simulate_user_activity_cb), monitor);
g_signal_connect(monitor->priv->listener, "show-message", G_CALLBACK(listener_show_message_cb), monitor);
+ g_signal_connect(monitor->priv->listener, "prepare-for-sleep", G_CALLBACK(listener_prepare_for_sleep_cb), monitor);
}
static void on_watcher_status_message_changed(GSWatcher* watcher, GParamSpec* pspec, GSMonitor* monitor)