diff options
author | James Booth <boothj5@gmail.com> | 2012-12-19 21:34:24 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2012-12-19 21:34:24 +0000 |
commit | a281d396d637d52337e50708c7f42a6df7b609bb (patch) | |
tree | 5d6d9566f8f7de7cb596b024639eaf375ec9e522 | |
parent | 402a54772efddb9aab2bc95edb0bc6a22ba4c5f6 (diff) | |
download | profani-tty-a281d396d637d52337e50708c7f42a6df7b609bb.tar.gz |
Fixed segfault when compiled with X11 but run in bare terminal
-rw-r--r-- | src/windows.c | 15 |
1 files 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; |