aboutsummaryrefslogtreecommitdiff
path: root/input.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-08-06 17:32:06 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-08-06 17:32:06 +0000
commit481a1cd6780233888fa1132242cb96f20ab14b73 (patch)
treebf508e829195de989fc44871767b8019804cd35d /input.c
parentmain: make all polled FDs non-blocking (diff)
selection/input: triple click selects an entire row
Diffstat (limited to 'input.c')
-rw-r--r--input.c34
1 files changed, 22 insertions, 12 deletions
diff --git a/input.c b/input.c
index e455d775..9e3ad64e 100644
--- a/input.c
+++ b/input.c
@@ -403,27 +403,37 @@ wl_pointer_button(void *data, struct wl_pointer *wl_pointer,
switch (state) {
case WL_POINTER_BUTTON_STATE_PRESSED: {
- bool double_click = false;
-
- struct timeval now;
+ /* Time since last click */
+ struct timeval now, since_last;
gettimeofday(&now, NULL);
-
- struct timeval since_last;
timersub(&now, &term->mouse.last_time, &since_last);
+
+ /* Double- or triple click? */
if (button == term->mouse.last_button &&
- since_last.tv_sec == 0 && since_last.tv_usec <= 300 * 1000)
+ since_last.tv_sec == 0 &&
+ since_last.tv_usec <= 300 * 1000)
{
- double_click = true;
- }
+ term->mouse.count++;
+ } else
+ term->mouse.count = 1;
if (button == BTN_LEFT) {
- if (double_click)
+ switch (term->mouse.count) {
+ case 1:
+ selection_start(term, term->mouse.col, term->mouse.row);
+ break;
+
+ case 2:
selection_mark_word(term, term->mouse.col, term->mouse.row,
term->kbd.ctrl, serial);
- else
- selection_start(term, term->mouse.col, term->mouse.row);
+ break;
+
+ case 3:
+ selection_mark_row(term, term->mouse.row, serial);
+ break;
+ }
} else {
- if (button == BTN_MIDDLE)
+ if (term->mouse.count == 1 && button == BTN_MIDDLE)
selection_from_primary(term);
selection_cancel(term);
}