From 156f1b626cdd4e22beea0fbdba5869e2f693020a Mon Sep 17 00:00:00 2001 From: Marc Deslauriers Date: Tue, 31 Jan 2012 20:28:26 +0400 Subject: properly lock even if already active If the screensaver is already active without a lock, and it got a request to lock, it would bail out without switching to a locked state. https://bugzilla.gnome.org/show_bug.cgi?id=668967 --- src/gs-monitor.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/gs-monitor.c b/src/gs-monitor.c index 56ef901..42dead3 100644 --- a/src/gs-monitor.c +++ b/src/gs-monitor.c @@ -174,18 +174,23 @@ static void gs_monitor_lock_screen(GSMonitor* monitor) { gboolean res; gboolean locked; + gboolean active; /* set lock flag before trying to activate screensaver in case something tries to react to the ActiveChanged signal */ gs_manager_get_lock_active(monitor->priv->manager, &locked); gs_manager_set_lock_active(monitor->priv->manager, TRUE); - res = gs_listener_set_active(monitor->priv->listener, TRUE); + active = gs_manager_get_active(monitor->priv->manager); - if (! res) - { - /* If we've failed then restore lock status */ - gs_manager_set_lock_active(monitor->priv->manager, locked); - gs_debug("Unable to lock the screen"); + if (!active) { + res = gs_listener_set_active(monitor->priv->listener, TRUE); + + if (!res) + { + /* if we've failed then restore lock status */ + gs_manager_set_lock_active(monitor->priv->manager, locked); + gs_debug("Unable to lock the screen"); + } } } -- cgit v1.2.1