From a281d396d637d52337e50708c7f42a6df7b609bb Mon Sep 17 00:00:00 2001 From: James Booth Date: Wed, 19 Dec 2012 21:34:24 +0000 Subject: [PATCH] Fixed segfault when compiled with X11 but run in bare terminal --- src/windows.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) 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;