diff options
Diffstat (limited to 'src/gs-monitor.c')
-rw-r--r-- | src/gs-monitor.c | 17 |
1 files changed, 11 insertions, 6 deletions
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"); + } } } |