1
1
mirror of https://github.com/profanity-im/profanity.git synced 2025-01-03 14:57:42 -05:00

Use profanity input for idle time when libxss not availalbe

This commit is contained in:
James Booth 2012-12-01 18:39:34 +00:00
parent fae848ea64
commit 1029c43002
3 changed files with 25 additions and 8 deletions

View File

@ -94,6 +94,10 @@ prof_run(const int disable_tls, char *log_level)
jabber_process_events(); jabber_process_events();
inp_get_char(&ch, inp, &size); inp_get_char(&ch, inp, &size);
if (ch != ERR) {
ui_reset_idle_time();
}
} }
inp[size++] = '\0'; inp[size++] = '\0';
@ -444,11 +448,12 @@ _process_input(char *inp)
static void static void
_handle_idle_time() _handle_idle_time()
{ {
// for development // for development
gint prefs_time = prefs_get_autoaway_time() * 1000; gint prefs_time = prefs_get_autoaway_time() * 1000;
// gint prefs_time = prefs_get_autoaway_time() * 60000; // gint prefs_time = prefs_get_autoaway_time() * 60000;
unsigned long idle_ms = ui_get_desktop_idle(); unsigned long idle_ms = ui_get_idle_time();
if (!idle) { if (!idle) {
if (idle_ms >= prefs_time) { if (idle_ms >= prefs_time) {
idle = TRUE; idle = TRUE;

View File

@ -76,9 +76,8 @@ void ui_disconnected(void);
void ui_handle_special_keys(const int * const ch); void ui_handle_special_keys(const int * const ch);
void ui_switch_win(const int i); void ui_switch_win(const int i);
gboolean ui_windows_full(void); gboolean ui_windows_full(void);
#ifdef HAVE_LIBXSS unsigned long ui_get_idle_time(void);
unsigned long ui_get_desktop_idle(void); void ui_reset_idle_time(void);
#endif
// create windows // create windows
void create_title_bar(void); void create_title_bar(void);

View File

@ -74,6 +74,8 @@ static int max_cols = 0;
static Display *display; static Display *display;
#endif #endif
static GTimer *ui_idle_time;
static void _set_current(int index); static void _set_current(int index);
static void _create_windows(void); static void _create_windows(void);
static void _cons_splash_logo(void); static void _cons_splash_logo(void);
@ -127,6 +129,7 @@ ui_init(void)
#ifdef HAVE_LIBXSS #ifdef HAVE_LIBXSS
display = XOpenDisplay(0); display = XOpenDisplay(0);
#endif #endif
ui_idle_time = g_timer_new();
dirty = TRUE; dirty = TRUE;
} }
@ -171,18 +174,28 @@ ui_refresh(void)
inp_put_back(); inp_put_back();
} }
#ifdef HAVE_LIBXSS
unsigned long unsigned long
ui_get_desktop_idle(void) ui_get_idle_time(void)
{ {
#ifdef HAVE_LIBXSS
XScreenSaverInfo *info = XScreenSaverAllocInfo(); XScreenSaverInfo *info = XScreenSaverAllocInfo();
XScreenSaverQueryInfo(display, DefaultRootWindow(display), info); XScreenSaverQueryInfo(display, DefaultRootWindow(display), info);
unsigned long result = info->idle; unsigned long result = info->idle;
XFree(info); XFree(info);
return result; return result;
} #else
gdouble seconds_elapsed = g_timer_elapsed(ui_idle_time);
unsigned long ms_elapsed = seconds_elapsed * 1000.0;
return ms_elapsed;
#endif #endif
}
void
ui_reset_idle_time(void)
{
g_timer_start(ui_idle_time);
}
void void
ui_close(void) ui_close(void)