diff --git a/src/windows.c b/src/windows.c index f0276a6e..94698667 100644 --- a/src/windows.c +++ b/src/windows.c @@ -203,11 +203,16 @@ ui_get_idle_time(void) { #ifdef HAVE_LIBXSS XScreenSaverInfo *info = XScreenSaverAllocInfo(); - XScreenSaverQueryInfo(display, DefaultRootWindow(display), info); - unsigned long result = info->idle; - XFree(info); - - return result; + if (info != NULL && display != NULL) { + XScreenSaverQueryInfo(display, DefaultRootWindow(display), info); + unsigned long result = info->idle; + XFree(info); + return result; + } else { + gdouble seconds_elapsed = g_timer_elapsed(ui_idle_time, NULL); + unsigned long ms_elapsed = seconds_elapsed * 1000.0; + return ms_elapsed; + } #else gdouble seconds_elapsed = g_timer_elapsed(ui_idle_time, NULL); unsigned long ms_elapsed = seconds_elapsed * 1000.0;