diff options
-rw-r--r-- | src/ui.c | 21 | ||||
-rw-r--r-- | src/ui.h | 2 | ||||
-rw-r--r-- | src/ui_elements.c | 6 |
3 files changed, 17 insertions, 12 deletions
@@ -186,11 +186,11 @@ do_ui_update(bool timed_out) } while (cur != NULL) { if (cur->cbs.ui_element != NULL) { - if ( (retval = cur->cbs.ui_element(cur->wnd, cur->data, timed_out)) != UICB_OK) - break; + if ( cur->cbs.ui_element(cur->wnd, cur->data, timed_out) != UICB_OK) + retval = UICB_ERR_CB; doupdate(); } else { - retval = UICB_ERR_CB; + retval = UICB_ERR_UNDEF; break; } cur = cur->next; @@ -231,7 +231,7 @@ ui_thrd(void *arg) while ( ui_ipc_getvalue(SEM_UI) > 0 ) { cnd_ret = ui_cond_timedwait(&cnd_update, &mtx_update, UILOOP_TIMEOUT); if (cnd_ret == 0) { - do_ui_update(false); + do_ui_update(true); } else if (cnd_ret == ETIMEDOUT) { do_ui_update(true); } @@ -241,12 +241,15 @@ ui_thrd(void *arg) } void -ui_thrd_force_update(bool force_all) +ui_thrd_force_update(bool force_all, bool timedout) { pthread_mutex_lock(&mtx_update); if (force_all) touchwin(wnd_main); - pthread_cond_signal(&cnd_update); + if (timedout) + pthread_cond_signal(&cnd_update); + else + do_ui_update(false); pthread_mutex_unlock(&mtx_update); } @@ -355,14 +358,16 @@ do_ui(void) pthread_mutex_unlock(&mtx_update); while ( ui_ipc_getvalue(SEM_UI) > 0 ) { - if ( (key = ui_wgetch(3000)) == ERR ) + if ( (key = ui_wgetch(10000)) == ERR ) continue; if ( process_key(key) != true ) { raise(SIGTERM); } - ui_thrd_force_update(false); + pthread_mutex_lock(&mtx_update); + do_ui_update(false); + pthread_mutex_unlock(&mtx_update); } stop_ui_thrd(); free_ui_elements(); @@ -71,7 +71,7 @@ int deactivate_ui_input(void *data); void -ui_thrd_force_update(bool force_all); +ui_thrd_force_update(bool force_all, bool timedout); void ui_thrd_suspend(void); diff --git a/src/ui_elements.c b/src/ui_elements.c index aae1aff..ec5a29e 100644 --- a/src/ui_elements.c +++ b/src/ui_elements.c @@ -69,7 +69,7 @@ show_info_wnd(struct txtwindow *wnd, char *_title, char *text, chtype fore, chty set_txtwindow_title(wnd, _title); set_txtwindow_text(wnd, text); ui_thrd_resume(); - ui_thrd_force_update(false); + ui_thrd_force_update(false, false); } static int @@ -87,7 +87,7 @@ passwd_input_cb(WINDOW *wnd, void *data, int key) clear_input(wnd, a); deactivate_input(pw_input); ui_thrd_resume(); - ui_thrd_force_update(false); + ui_thrd_force_update(false, false); ui_ipc_msgrecv(MQ_IF, ipc_buf); show_info_wnd(infownd, "BUSY", ipc_buf, COLOR_PAIR(5), COLOR_PAIR(5), true, false); @@ -104,7 +104,7 @@ passwd_input_cb(WINDOW *wnd, void *data, int key) set_txtwindow_active(infownd, false); activate_input(pw_input); ui_thrd_resume(); - ui_thrd_force_update(true); + ui_thrd_force_update(true, false); ui_ipc_sempost(SEM_IN); break; |