mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Use profanity input for idle time when libxss not availalbe
This commit is contained in:
parent
fae848ea64
commit
1029c43002
@ -94,6 +94,10 @@ prof_run(const int disable_tls, char *log_level)
|
||||
jabber_process_events();
|
||||
|
||||
inp_get_char(&ch, inp, &size);
|
||||
|
||||
if (ch != ERR) {
|
||||
ui_reset_idle_time();
|
||||
}
|
||||
}
|
||||
|
||||
inp[size++] = '\0';
|
||||
@ -444,11 +448,12 @@ _process_input(char *inp)
|
||||
static void
|
||||
_handle_idle_time()
|
||||
{
|
||||
// for development
|
||||
// for development
|
||||
gint prefs_time = prefs_get_autoaway_time() * 1000;
|
||||
|
||||
// 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_ms >= prefs_time) {
|
||||
idle = TRUE;
|
||||
|
5
src/ui.h
5
src/ui.h
@ -76,9 +76,8 @@ void ui_disconnected(void);
|
||||
void ui_handle_special_keys(const int * const ch);
|
||||
void ui_switch_win(const int i);
|
||||
gboolean ui_windows_full(void);
|
||||
#ifdef HAVE_LIBXSS
|
||||
unsigned long ui_get_desktop_idle(void);
|
||||
#endif
|
||||
unsigned long ui_get_idle_time(void);
|
||||
void ui_reset_idle_time(void);
|
||||
|
||||
// create windows
|
||||
void create_title_bar(void);
|
||||
|
@ -74,6 +74,8 @@ static int max_cols = 0;
|
||||
static Display *display;
|
||||
#endif
|
||||
|
||||
static GTimer *ui_idle_time;
|
||||
|
||||
static void _set_current(int index);
|
||||
static void _create_windows(void);
|
||||
static void _cons_splash_logo(void);
|
||||
@ -127,6 +129,7 @@ ui_init(void)
|
||||
#ifdef HAVE_LIBXSS
|
||||
display = XOpenDisplay(0);
|
||||
#endif
|
||||
ui_idle_time = g_timer_new();
|
||||
dirty = TRUE;
|
||||
}
|
||||
|
||||
@ -171,18 +174,28 @@ ui_refresh(void)
|
||||
inp_put_back();
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBXSS
|
||||
unsigned long
|
||||
ui_get_desktop_idle(void)
|
||||
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;
|
||||
}
|
||||
#else
|
||||
gdouble seconds_elapsed = g_timer_elapsed(ui_idle_time);
|
||||
unsigned long ms_elapsed = seconds_elapsed * 1000.0;
|
||||
return ms_elapsed;
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
ui_reset_idle_time(void)
|
||||
{
|
||||
g_timer_start(ui_idle_time);
|
||||
}
|
||||
|
||||
void
|
||||
ui_close(void)
|
||||
|
Loading…
Reference in New Issue
Block a user