From f191bcc3a6139e4fcf425e8620c5a8ddd6d8e72e Mon Sep 17 00:00:00 2001 From: Ali Akbar Date: Mon, 26 Aug 2019 20:31:54 +0700 Subject: 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. --- src/gs-monitor.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/gs-monitor.c') 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) -- cgit v1.2.1