1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Fixed segfault when compiled with X11 but run in bare terminal

This commit is contained in:
James Booth 2012-12-19 21:34:24 +00:00
parent 402a54772e
commit a281d396d6

View File

@ -203,11 +203,16 @@ ui_get_idle_time(void)
{ {
#ifdef HAVE_LIBXSS #ifdef HAVE_LIBXSS
XScreenSaverInfo *info = XScreenSaverAllocInfo(); XScreenSaverInfo *info = XScreenSaverAllocInfo();
XScreenSaverQueryInfo(display, DefaultRootWindow(display), info); if (info != NULL && display != NULL) {
unsigned long result = info->idle; XScreenSaverQueryInfo(display, DefaultRootWindow(display), info);
XFree(info); unsigned long result = info->idle;
XFree(info);
return result; 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 #else
gdouble seconds_elapsed = g_timer_elapsed(ui_idle_time, NULL); gdouble seconds_elapsed = g_timer_elapsed(ui_idle_time, NULL);
unsigned long ms_elapsed = seconds_elapsed * 1000.0; unsigned long ms_elapsed = seconds_elapsed * 1000.0;