aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac2
-rw-r--r--src/aconfig.h.in3
-rw-r--r--src/ui.c20
-rw-r--r--src/ui_elements.c19
4 files changed, 24 insertions, 20 deletions
diff --git a/configure.ac b/configure.ac
index dc50072..bafaddc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -57,7 +57,7 @@ AC_FUNC_STRNLEN
AC_FUNC_STAT
AC_FUNC_MKTIME
AC_FUNC_VPRINTF
-AC_CHECK_FUNCS([clock_gettime asprintf system printf fprintf mkfifo stat open close fork gettimeofday memmove memcpy memset strdup strndup strerror strstr strlen strnlen strtol],,[AC_MSG_ERROR([*** Missing essential functions.])])
+AC_CHECK_FUNCS([clock_gettime asprintf system printf fprintf mkfifo stat open close fork memmove memcpy memset strdup strndup strerror strstr strlen strnlen strtol],,[AC_MSG_ERROR([*** Missing essential functions.])])
AC_DEFINE([HAVE_CONFIG], [1], [Do NOT change THIS!])
LDFLAGS="${LDFLAGS} -pthread -lrt -lncurses"
diff --git a/src/aconfig.h.in b/src/aconfig.h.in
index f690396..a24ff8d 100644
--- a/src/aconfig.h.in
+++ b/src/aconfig.h.in
@@ -40,9 +40,6 @@
/* Define to 1 if you have the `getpagesize' function. */
#undef HAVE_GETPAGESIZE
-/* Define to 1 if you have the `gettimeofday' function. */
-#undef HAVE_GETTIMEOFDAY
-
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
diff --git a/src/ui.c b/src/ui.c
index acf04f5..a3e43c2 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -7,6 +7,7 @@
#include <semaphore.h>
#include <string.h>
#include <ncurses.h>
+#include <signal.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -202,22 +203,20 @@ ui_thrd(void *arg)
{
int cnd_ret;
struct timespec now;
- struct timespec wait;
- //gettimeofday(&now, NULL);
- clock_gettime(CLOCK_REALTIME, &now);
- wait.tv_sec = now.tv_sec + UILOOP_TIMEOUT;
- wait.tv_nsec = now.tv_nsec * 1000;
do_ui_update(true);
ui_ipc_sempost(SEM_RD);
pthread_mutex_lock(&mtx_update);
+ clock_gettime(CLOCK_REALTIME, &now);
+ now.tv_sec += UILOOP_TIMEOUT;
while ( ui_ipc_getvalue(SEM_UI) > 0 ) {
- cnd_ret = pthread_cond_timedwait(&cnd_update, &mtx_update, &wait);
+ cnd_ret = pthread_cond_timedwait(&cnd_update, &mtx_update, &now);
pthread_mutex_lock(&mtx_busy);
do_ui_update( (cnd_ret == ETIMEDOUT ? true : false) );
pthread_mutex_unlock(&mtx_busy);
if (cnd_ret == ETIMEDOUT) {
- wait.tv_sec += UILOOP_TIMEOUT;
+ clock_gettime(CLOCK_REALTIME, &now);
+ now.tv_sec += UILOOP_TIMEOUT;
}
}
pthread_mutex_unlock(&mtx_update);
@@ -235,7 +234,6 @@ ui_thrd_force_update(void)
void
ui_thrd_suspend(void)
{
- ui_thrd_force_update();
pthread_mutex_lock(&mtx_busy);
}
@@ -243,7 +241,6 @@ void
ui_thrd_resume(void)
{
pthread_mutex_unlock(&mtx_busy);
- ui_thrd_force_update();
}
WINDOW *
@@ -265,6 +262,7 @@ init_ui(void)
raw();
keypad(stdscr, TRUE);
noecho();
+ nodelay(stdscr, TRUE);
cbreak();
return (wnd_main);
}
@@ -305,13 +303,13 @@ do_ui(void)
}
ui_ipc_semwait(SEM_RD);
pthread_mutex_unlock(&mtx_update);
- wtimeout(stdscr, 1000);
+ wtimeout(stdscr, 500);
while ( ui_ipc_getvalue(SEM_UI) > 0 ) {
if ((key = wgetch(wnd_main)) == ERR) {
continue;
}
if ( process_key(key) != true ) {
- ui_ipc_semtrywait(SEM_UI);
+ raise(SIGTERM);
}
ui_thrd_force_update();
}
diff --git a/src/ui_elements.c b/src/ui_elements.c
index 9f4994d..535bc0c 100644
--- a/src/ui_elements.c
+++ b/src/ui_elements.c
@@ -66,7 +66,7 @@ passwd_input_cb(WINDOW *wnd, void *data, int key)
char ipc_buf[IPC_MQSIZ+1];
memset(ipc_buf, '\0', IPC_MQSIZ+1);
- wtimeout(stdscr, -1);
+// wtimeout(stdscr, -1);
switch (key) {
case UIKEY_ENTER:
ui_ipc_msgsend(MQ_PW, a->input);
@@ -84,6 +84,7 @@ passwd_input_cb(WINDOW *wnd, void *data, int key)
set_txtwindow_text(infownd, ipc_buf);
set_txtwindow_active(infownd, true);
ui_thrd_resume();
+ ui_thrd_force_update();
sleep(2);
ui_ipc_msgrecv(MQ_IF, ipc_buf);
@@ -101,14 +102,22 @@ passwd_input_cb(WINDOW *wnd, void *data, int key)
activate_input(pw_input);
ui_thrd_resume();
- //ui_thrd_force_update();
ui_ipc_sempost(SEM_IN);
break;
case UIKEY_BACKSPACE:
del_input(wnd, a);
- //ui_thrd_force_update();
break;
case UIKEY_ESC:
+ wtimeout(stdscr, 0);
+ ui_thrd_suspend();
+ deactivate_input(pw_input);
+ set_txtwindow_active(infownd, true);
+ set_txtwindow_color(infownd, COLOR_PAIR(5), COLOR_PAIR(5));
+ set_txtwindow_title(infownd, "BUSY");
+ set_txtwindow_text(infownd, "bye bye");
+ ui_thrd_resume();
+ ui_thrd_force_update();
+ sleep(2);
return DOUI_ERR;
case UIKEY_DOWN:
case UIKEY_UP:
@@ -119,9 +128,9 @@ passwd_input_cb(WINDOW *wnd, void *data, int key)
break;
default:
add_input(wnd, a, key);
- //ui_thrd_force_update();
}
- wtimeout(stdscr, 1000);
+// wtimeout(stdscr, 1000);
+ refresh();
return DOUI_OK;
}