diff options
| author | Simon Effenberg <savar@schuldeigen.de> | 2015-01-08 23:43:11 +0100 |
|---|---|---|
| committer | Simon Effenberg <savar@schuldeigen.de> | 2015-01-12 08:08:07 +0100 |
| commit | c7ff3255b8bd4bed2f825255a4fe28940db533b2 (patch) | |
| tree | 8e474ace8ff803cd1c932a451d811a99d6a7cec7 /src/ui | |
| parent | 0d0ed9b7ca4b9055fece7ddc4e2430b900cbb355 (diff) | |
| download | profani-tty-c7ff3255b8bd4bed2f825255a4fe28940db533b2.tar.gz | |
trying to block (and save cpu power) more dynamically
instead of blocking too long if inpblock is set to something like
500ms the input timeout is not set directly to inpblock but is
increasing dynamically from 0 to inpblock by a little algorithm
FIXME: the call from the win_* method to the ui_input_* method looks
wrong.. this causes a cross reference which shouldn't be
Diffstat (limited to 'src/ui')
| -rw-r--r-- | src/ui/core.c | 30 | ||||
| -rw-r--r-- | src/ui/inputwin.c | 4 | ||||
| -rw-r--r-- | src/ui/inputwin.h | 4 | ||||
| -rw-r--r-- | src/ui/ui.h | 2 | ||||
| -rw-r--r-- | src/ui/window.c | 4 |
5 files changed, 35 insertions, 9 deletions
diff --git a/src/ui/core.c b/src/ui/core.c index be16dfad..3b53b4ed 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -180,7 +180,11 @@ ui_get_char(char *input, int *size, int *result) wint_t ch = inp_get_char(input, size, result); if (ch != ERR && *result != ERR) { ui_reset_idle_time(); + ui_input_nonblocking(TRUE); + } else { + ui_input_nonblocking(FALSE); } + return ch; } @@ -197,9 +201,29 @@ ui_replace_input(char *input, const char * const new_input, int *size) } void -ui_input_nonblocking(void) +ui_input_nonblocking(gboolean reset) { - inp_non_block(); + static gint timeout = 0; + static gint no_input_count = 0; + + if (reset) { + timeout = 0; + no_input_count = 0; + } + + if (timeout < prefs_get_inpblock()) { + no_input_count++; + + if (no_input_count % 10 == 0) { + timeout += no_input_count; + + if (timeout > prefs_get_inpblock()) { + timeout = prefs_get_inpblock(); + } + } + } + + inp_non_block(timeout); } void @@ -2218,7 +2242,7 @@ ui_ask_password(void) status_bar_update_virtual(); inp_block(); inp_get_password(passwd); - inp_non_block(); + inp_non_block(prefs_get_inpblock()); return passwd; } diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c index 19318745..a6877a86 100644 --- a/src/ui/inputwin.c +++ b/src/ui/inputwin.c @@ -120,9 +120,9 @@ inp_win_resize(void) } void -inp_non_block(void) +inp_non_block(gint timeout) { - wtimeout(inp_win, prefs_get_inpblock()); + wtimeout(inp_win, timeout); } void diff --git a/src/ui/inputwin.h b/src/ui/inputwin.h index eae20a51..b5a26c10 100644 --- a/src/ui/inputwin.h +++ b/src/ui/inputwin.h @@ -40,9 +40,9 @@ wint_t inp_get_char(char *input, int *size, int *result); void inp_win_reset(void); void inp_win_resize(void); void inp_put_back(void); -void inp_non_block(void); +void inp_non_block(gint); void inp_block(void); void inp_get_password(char *passwd); void inp_replace_input(char *input, const char * const new_input, int *size); -#endif
\ No newline at end of file +#endif diff --git a/src/ui/ui.h b/src/ui/ui.h index 32484b9e..e28914ff 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -232,7 +232,7 @@ void ui_statusbar_new(const int win); wint_t ui_get_char(char *input, int *size, int *result); void ui_input_clear(void); -void ui_input_nonblocking(void); +void ui_input_nonblocking(gboolean); void ui_replace_input(char *input, const char * const new_input, int *size); void ui_invalid_command_usage(const char * const usage, void (*setting_func)(void)); diff --git a/src/ui/window.c b/src/ui/window.c index caef36df..3a45ab01 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -740,6 +740,8 @@ win_save_print(ProfWin *window, const char show_char, GTimeVal *tstamp, buffer_push(window->layout->buffer, show_char, time, flags, theme_item, from, message); _win_print(window, show_char, time, flags, theme_item, from, message); + // TODO: cross-reference.. this should be replaced by a real event-based system + ui_input_nonblocking(TRUE); } void @@ -952,4 +954,4 @@ win_printline_nowrap(WINDOW *win, char *msg) waddnstr(win, msg, maxx); wmove(win, cury+1, 0); -}
\ No newline at end of file +} |