Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
--- gnome-screensaver-2.30.0.orig/src/gs-lock-plug.c
+++ gnome-screensaver-2.30.0/src/gs-lock-plug.c
@@ -106,6 +106,7 @@
char *status_message;
guint timeout;
+ time_t timeout_started;
guint cancel_timeout_id;
guint auth_check_idle_id;
@@ -212,6 +213,7 @@
if (plug->priv->cancel_timeout_id > 0) {
g_source_remove (plug->priv->cancel_timeout_id);
plug->priv->cancel_timeout_id = 0;
+ plug->priv->timeout_started = 0;
}
}
@@ -263,9 +265,27 @@
return FALSE;
}
+static void
+restart_cancel_timeout (GSLockPlug *plug);
+
static gboolean
dialog_timed_out (GSLockPlug *plug)
{
+ // We need to check for time warps, to avoid the case
+ // where a "already-expired" dialog is the first thing a user sees
+ // when the system comes out of a sleep.
+ time_t begun = plug->priv->timeout_started;
+ time_t now = time( NULL );
+
+ guint expected_sec = plug->priv->timeout / 1000;
+ guint actual_sec = ( now - begun );
+
+ // 30 seconds longer then the timeout ought to do it.
+ if ( actual_sec > ( expected_sec + 30 ) ) {
+ restart_cancel_timeout( plug );
+ return FALSE;
+ }
+
gs_lock_plug_set_sensitive (plug, FALSE);
set_status_text (plug, _("Time has expired."));
@@ -321,6 +341,7 @@
{
remove_cancel_timeout (plug);
+ plug->priv->timeout_started = time( NULL );
plug->priv->cancel_timeout_id = g_timeout_add (plug->priv->timeout,
(GSourceFunc)dialog_timed_out,
plug);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment