This commit is contained in:
Přemysl Eric Janouch 2017-06-05 20:18:56 +02:00
parent 34bbff2f71
commit cadc846fd4
Signed by: p
GPG Key ID: B715679E3A361BE6
1 changed files with 38 additions and 35 deletions

View File

@ -2973,7 +2973,6 @@ static void
mpd_on_io_hook (void *user_data, bool outgoing, const char *line) mpd_on_io_hook (void *user_data, bool outgoing, const char *line)
{ {
(void) user_data; (void) user_data;
if (outgoing) if (outgoing)
debug_tab_push (xstrdup_printf ("<< %s", line), APP_ATTR (OUTGOING)); debug_tab_push (xstrdup_printf ("<< %s", line), APP_ATTR (OUTGOING));
else else
@ -3091,20 +3090,8 @@ signals_setup_handlers (void)
// --- Initialisation, event handling ------------------------------------------ // --- Initialisation, event handling ------------------------------------------
static void static void
app_on_tty_readable (const struct pollfd *fd, void *user_data) app_on_tty_event (termo_key_t *event, int64_t event_ts)
{ {
(void) user_data;
if (fd->revents & ~(POLLIN | POLLHUP | POLLERR))
print_debug ("fd %d: unexpected revents: %d", fd->fd, fd->revents);
poller_timer_reset (&g.tk_timer);
termo_advisereadable (g.tk);
termo_key_t event;
int64_t event_ts = clock_msec (CLOCK_BEST);
termo_result_t res;
while ((res = termo_getkey (g.tk, &event)) == TERMO_RES_KEY)
{
// Simple double click detection via release--press delay, only a bit // Simple double click detection via release--press delay, only a bit
// complicated by the fact that we don't know what's being released // complicated by the fact that we don't know what's being released
static termo_key_t last_event; static termo_key_t last_event;
@ -3113,7 +3100,7 @@ app_on_tty_readable (const struct pollfd *fd, void *user_data)
int y, x, button, y_last, x_last; int y, x, button, y_last, x_last;
termo_mouse_event_t type, type_last; termo_mouse_event_t type, type_last;
if (termo_interpret_mouse (g.tk, &event, &type, &button, &y, &x)) if (termo_interpret_mouse (g.tk, event, &type, &button, &y, &x))
{ {
bool double_click = termo_interpret_mouse bool double_click = termo_interpret_mouse
(g.tk, &last_event, &type_last, NULL, &y_last, &x_last) (g.tk, &last_event, &type_last, NULL, &y_last, &x_last)
@ -3129,12 +3116,28 @@ app_on_tty_readable (const struct pollfd *fd, void *user_data)
else if (type == TERMO_MOUSE_PRESS) else if (type == TERMO_MOUSE_PRESS)
last_button = button; last_button = button;
} }
else if (!app_process_termo_event (&event)) else if (!app_process_termo_event (event))
beep (); beep ();
last_event = event; last_event = *event;
last_event_ts = event_ts; last_event_ts = event_ts;
} }
static void
app_on_tty_readable (const struct pollfd *fd, void *user_data)
{
(void) user_data;
if (fd->revents & ~(POLLIN | POLLHUP | POLLERR))
print_debug ("fd %d: unexpected revents: %d", fd->fd, fd->revents);
poller_timer_reset (&g.tk_timer);
termo_advisereadable (g.tk);
termo_key_t event;
int64_t event_ts = clock_msec (CLOCK_BEST);
termo_result_t res;
while ((res = termo_getkey (g.tk, &event)) == TERMO_RES_KEY)
app_on_tty_event (&event, event_ts);
if (res == TERMO_RES_AGAIN) if (res == TERMO_RES_AGAIN)
poller_timer_set (&g.tk_timer, termo_get_waittime (g.tk)); poller_timer_set (&g.tk_timer, termo_get_waittime (g.tk));