mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-27 07:36:22 +00:00
Moved input blocking code to inputwin.c
This commit is contained in:
@@ -99,7 +99,6 @@ prof_run(const int disable_tls, char *log_level, char *account_name)
|
|||||||
void
|
void
|
||||||
prof_handle_idle(void)
|
prof_handle_idle(void)
|
||||||
{
|
{
|
||||||
cons_debug("IDLE");
|
|
||||||
jabber_conn_status_t status = jabber_get_connection_status();
|
jabber_conn_status_t status = jabber_get_connection_status();
|
||||||
if (status == JABBER_CONNECTED) {
|
if (status == JABBER_CONNECTED) {
|
||||||
GSList *recipients = ui_get_chat_recipients();
|
GSList *recipients = ui_get_chat_recipients();
|
||||||
@@ -121,7 +120,6 @@ prof_handle_idle(void)
|
|||||||
void
|
void
|
||||||
prof_handle_activity(void)
|
prof_handle_activity(void)
|
||||||
{
|
{
|
||||||
cons_debug("ACTIVITY");
|
|
||||||
win_type_t win_type = ui_current_win_type();
|
win_type_t win_type = ui_current_win_type();
|
||||||
jabber_conn_status_t status = jabber_get_connection_status();
|
jabber_conn_status_t status = jabber_get_connection_status();
|
||||||
|
|
||||||
|
|||||||
@@ -215,33 +215,7 @@ ui_input_clear(void)
|
|||||||
void
|
void
|
||||||
ui_input_nonblocking(gboolean reset)
|
ui_input_nonblocking(gboolean reset)
|
||||||
{
|
{
|
||||||
static gint timeout = 0;
|
inp_nonblocking(reset);
|
||||||
static gint no_input_count = 0;
|
|
||||||
|
|
||||||
if (! prefs_get_boolean(PREF_INPBLOCK_DYNAMIC)) {
|
|
||||||
inp_non_block(prefs_get_inpblock());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
log_info("TIMEOUT: %d", timeout);
|
|
||||||
inp_non_block(timeout);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -2250,7 +2224,8 @@ ui_ask_password(void)
|
|||||||
status_bar_update_virtual();
|
status_bar_update_virtual();
|
||||||
inp_block();
|
inp_block();
|
||||||
inp_get_password(passwd);
|
inp_get_password(passwd);
|
||||||
inp_non_block(prefs_get_inpblock());
|
// inp_non_block(prefs_get_inpblock());
|
||||||
|
inp_nonblocking(TRUE);
|
||||||
|
|
||||||
return passwd;
|
return passwd;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,7 +66,9 @@
|
|||||||
static WINDOW *inp_win;
|
static WINDOW *inp_win;
|
||||||
|
|
||||||
static struct timeval p_rl_timeout;
|
static struct timeval p_rl_timeout;
|
||||||
static int timeout_millis = 0;
|
static gint inp_timeout = 0;
|
||||||
|
static gint no_input_count = 0;
|
||||||
|
|
||||||
static fd_set fds;
|
static fd_set fds;
|
||||||
static int r;
|
static int r;
|
||||||
static gboolean cmd_result = TRUE;
|
static gboolean cmd_result = TRUE;
|
||||||
@@ -95,7 +97,7 @@ create_input_window(void)
|
|||||||
ESCDELAY = 25;
|
ESCDELAY = 25;
|
||||||
#endif
|
#endif
|
||||||
p_rl_timeout.tv_sec = 0;
|
p_rl_timeout.tv_sec = 0;
|
||||||
p_rl_timeout.tv_usec = timeout_millis * 1000;
|
p_rl_timeout.tv_usec = inp_timeout * 1000;
|
||||||
rl_callback_handler_install(NULL, cb_linehandler);
|
rl_callback_handler_install(NULL, cb_linehandler);
|
||||||
|
|
||||||
inp_win = newpad(1, INP_WIN_MAX);
|
inp_win = newpad(1, INP_WIN_MAX);
|
||||||
@@ -144,9 +146,29 @@ offset_to_col(char *str, int offset)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
inp_non_block(gint block_timeout)
|
inp_nonblocking(gboolean reset)
|
||||||
{
|
{
|
||||||
timeout_millis = block_timeout;
|
if (! prefs_get_boolean(PREF_INPBLOCK_DYNAMIC)) {
|
||||||
|
inp_timeout = prefs_get_inpblock();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reset) {
|
||||||
|
inp_timeout = 0;
|
||||||
|
no_input_count = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inp_timeout < prefs_get_inpblock()) {
|
||||||
|
no_input_count++;
|
||||||
|
|
||||||
|
if (no_input_count % 10 == 0) {
|
||||||
|
inp_timeout += no_input_count;
|
||||||
|
|
||||||
|
if (inp_timeout > prefs_get_inpblock()) {
|
||||||
|
inp_timeout = prefs_get_inpblock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -181,13 +203,16 @@ inp_readline(void)
|
|||||||
if (rl_line_buffer && rl_line_buffer[0] != '/') {
|
if (rl_line_buffer && rl_line_buffer[0] != '/') {
|
||||||
prof_handle_activity();
|
prof_handle_activity();
|
||||||
}
|
}
|
||||||
|
ui_reset_idle_time();
|
||||||
|
inp_nonblocking(TRUE);
|
||||||
inp_write(rl_line_buffer, rl_point);
|
inp_write(rl_line_buffer, rl_point);
|
||||||
} else {
|
} else {
|
||||||
|
inp_nonblocking(FALSE);
|
||||||
prof_handle_idle();
|
prof_handle_idle();
|
||||||
}
|
}
|
||||||
|
|
||||||
p_rl_timeout.tv_sec = 0;
|
p_rl_timeout.tv_sec = 0;
|
||||||
p_rl_timeout.tv_usec = timeout_millis * 1000;
|
p_rl_timeout.tv_usec = inp_timeout * 1000;
|
||||||
|
|
||||||
return cmd_result;
|
return cmd_result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,7 @@
|
|||||||
|
|
||||||
void create_input_window(void);
|
void create_input_window(void);
|
||||||
gboolean inp_readline(void);
|
gboolean inp_readline(void);
|
||||||
|
void inp_nonblocking(gboolean reset);
|
||||||
void inp_close(void);
|
void inp_close(void);
|
||||||
char* inp_read(int *key_type, wint_t *ch);
|
char* inp_read(int *key_type, wint_t *ch);
|
||||||
void inp_win_clear(void);
|
void inp_win_clear(void);
|
||||||
|
|||||||
Reference in New Issue
Block a user