mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-02 07:15:31 -04:00
input: handle double/triple click state regardless of surface
This commit is contained in:
parent
cbf657e2d2
commit
7b51d6919d
1 changed files with 23 additions and 21 deletions
44
input.c
44
input.c
|
|
@ -849,6 +849,28 @@ wl_pointer_button(void *data, struct wl_pointer *wl_pointer,
|
||||||
|
|
||||||
assert(term != NULL);
|
assert(term != NULL);
|
||||||
|
|
||||||
|
/* Update double/triple click state */
|
||||||
|
if (state == WL_POINTER_BUTTON_STATE_PRESSED) {
|
||||||
|
/* Time since last click */
|
||||||
|
struct timeval now, since_last;
|
||||||
|
gettimeofday(&now, NULL);
|
||||||
|
timersub(&now, &wayl->mouse.last_time, &since_last);
|
||||||
|
|
||||||
|
/* Double- or triple click? */
|
||||||
|
if (button == wayl->mouse.last_button &&
|
||||||
|
since_last.tv_sec == 0 &&
|
||||||
|
since_last.tv_usec <= 300 * 1000)
|
||||||
|
{
|
||||||
|
wayl->mouse.count++;
|
||||||
|
} else
|
||||||
|
wayl->mouse.count = 1;
|
||||||
|
|
||||||
|
wayl->mouse.button = button; /* For motion events */
|
||||||
|
wayl->mouse.last_button = button;
|
||||||
|
wayl->mouse.last_time = now;
|
||||||
|
} else
|
||||||
|
wayl->mouse.button = 0; /* For motion events */
|
||||||
|
|
||||||
switch (term->active_surface) {
|
switch (term->active_surface) {
|
||||||
case TERM_SURF_NONE:
|
case TERM_SURF_NONE:
|
||||||
assert(false);
|
assert(false);
|
||||||
|
|
@ -910,28 +932,12 @@ wl_pointer_button(void *data, struct wl_pointer *wl_pointer,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert(term->active_surface == TERM_SURF_GRID);
|
||||||
if (term->active_surface != TERM_SURF_GRID)
|
|
||||||
return;
|
|
||||||
|
|
||||||
search_cancel(term);
|
search_cancel(term);
|
||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case WL_POINTER_BUTTON_STATE_PRESSED: {
|
case WL_POINTER_BUTTON_STATE_PRESSED: {
|
||||||
/* Time since last click */
|
|
||||||
struct timeval now, since_last;
|
|
||||||
gettimeofday(&now, NULL);
|
|
||||||
timersub(&now, &wayl->mouse.last_time, &since_last);
|
|
||||||
|
|
||||||
/* Double- or triple click? */
|
|
||||||
if (button == wayl->mouse.last_button &&
|
|
||||||
since_last.tv_sec == 0 &&
|
|
||||||
since_last.tv_usec <= 300 * 1000)
|
|
||||||
{
|
|
||||||
wayl->mouse.count++;
|
|
||||||
} else
|
|
||||||
wayl->mouse.count = 1;
|
|
||||||
|
|
||||||
if (button == BTN_LEFT) {
|
if (button == BTN_LEFT) {
|
||||||
switch (wayl->mouse.count) {
|
switch (wayl->mouse.count) {
|
||||||
case 1:
|
case 1:
|
||||||
|
|
@ -955,9 +961,6 @@ wl_pointer_button(void *data, struct wl_pointer *wl_pointer,
|
||||||
selection_cancel(term);
|
selection_cancel(term);
|
||||||
}
|
}
|
||||||
|
|
||||||
wayl->mouse.button = button; /* For motion events */
|
|
||||||
wayl->mouse.last_button = button;
|
|
||||||
wayl->mouse.last_time = now;
|
|
||||||
term_mouse_down(term, button, wayl->mouse.row, wayl->mouse.col);
|
term_mouse_down(term, button, wayl->mouse.row, wayl->mouse.col);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -968,7 +971,6 @@ wl_pointer_button(void *data, struct wl_pointer *wl_pointer,
|
||||||
else
|
else
|
||||||
selection_finalize(term, serial);
|
selection_finalize(term, serial);
|
||||||
|
|
||||||
wayl->mouse.button = 0; /* For motion events */
|
|
||||||
term_mouse_up(term, button, wayl->mouse.row, wayl->mouse.col);
|
term_mouse_up(term, button, wayl->mouse.row, wayl->mouse.col);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue