summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/server-client.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2020-03-31 11:38:35 +0000
committernicm <nicm@openbsd.org>2020-03-31 11:38:35 +0000
commita7a9c343b801c7ebb2ee9c8b2218e3d75c8c0d2d (patch)
treef56675880a35b42e927ab18a7ca018de0efab4b5 /usr.bin/tmux/server-client.c
parentFix MIMO rates with firmware-based rate scaling in iwm(4). (diff)
downloadwireguard-openbsd-a7a9c343b801c7ebb2ee9c8b2218e3d75c8c0d2d.tar.xz
wireguard-openbsd-a7a9c343b801c7ebb2ee9c8b2218e3d75c8c0d2d.zip
Add a "second click" key type which is fired for the second click of a
double click, even if the timer hasn't expired to confirm it isn't actually a triple click. Provides a way for people who don't care about triple clicks or can make their commands have no side effects to avoid the double click timer delay.
Diffstat (limited to 'usr.bin/tmux/server-client.c')
-rw-r--r--usr.bin/tmux/server-client.c65
1 files changed, 56 insertions, 9 deletions
diff --git a/usr.bin/tmux/server-client.c b/usr.bin/tmux/server-client.c
index 7811df2b3a8..b58adc3c6ff 100644
--- a/usr.bin/tmux/server-client.c
+++ b/usr.bin/tmux/server-client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server-client.c,v 1.310 2020/03/31 07:00:34 nicm Exp $ */
+/* $OpenBSD: server-client.c,v 1.311 2020/03/31 11:38:35 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -440,6 +440,7 @@ server_client_check_mouse(struct client *c, struct key_event *event)
UP,
DRAG,
WHEEL,
+ SECOND,
DOUBLE,
TRIPLE } type = NOTYPE;
enum { NOWHERE,
@@ -493,9 +494,10 @@ server_client_check_mouse(struct client *c, struct key_event *event)
evtimer_del(&c->click_timer);
c->flags &= ~CLIENT_DOUBLECLICK;
if (m->b == c->click_button) {
- type = NOTYPE;
+ type = SECOND;
+ x = m->x, y = m->y, b = m->b;
+ log_debug("second-click at %u,%u", x, y);
c->flags |= CLIENT_TRIPLECLICK;
- goto add_timer;
}
} else if (c->flags & CLIENT_TRIPLECLICK) {
evtimer_del(&c->click_timer);
@@ -507,13 +509,12 @@ server_client_check_mouse(struct client *c, struct key_event *event)
ignore = 1;
goto have_event;
}
- } else
+ } else {
+ type = DOWN;
+ x = m->x, y = m->y, b = m->b;
+ log_debug("down at %u,%u", x, y);
c->flags |= CLIENT_DOUBLECLICK;
-
- add_timer:
- type = DOWN;
- x = m->x, y = m->y, b = m->b;
- log_debug("down at %u,%u", x, y);
+ }
if (KEYC_CLICK_TIMEOUT != 0) {
memcpy(&c->click_event, m, sizeof c->click_event);
@@ -877,6 +878,52 @@ have_event:
break;
}
break;
+ case SECOND:
+ switch (MOUSE_BUTTONS(b)) {
+ case 0:
+ if (where == PANE)
+ key = KEYC_SECONDCLICK1_PANE;
+ if (where == STATUS)
+ key = KEYC_SECONDCLICK1_STATUS;
+ if (where == STATUS_LEFT)
+ key = KEYC_SECONDCLICK1_STATUS_LEFT;
+ if (where == STATUS_RIGHT)
+ key = KEYC_SECONDCLICK1_STATUS_RIGHT;
+ if (where == STATUS_DEFAULT)
+ key = KEYC_SECONDCLICK1_STATUS_DEFAULT;
+ if (where == BORDER)
+ key = KEYC_SECONDCLICK1_BORDER;
+ break;
+ case 1:
+ if (where == PANE)
+ key = KEYC_SECONDCLICK2_PANE;
+ if (where == STATUS)
+ key = KEYC_SECONDCLICK2_STATUS;
+ if (where == STATUS_LEFT)
+ key = KEYC_SECONDCLICK2_STATUS_LEFT;
+ if (where == STATUS_RIGHT)
+ key = KEYC_SECONDCLICK2_STATUS_RIGHT;
+ if (where == STATUS_DEFAULT)
+ key = KEYC_SECONDCLICK2_STATUS_DEFAULT;
+ if (where == BORDER)
+ key = KEYC_SECONDCLICK2_BORDER;
+ break;
+ case 2:
+ if (where == PANE)
+ key = KEYC_SECONDCLICK3_PANE;
+ if (where == STATUS)
+ key = KEYC_SECONDCLICK3_STATUS;
+ if (where == STATUS_LEFT)
+ key = KEYC_SECONDCLICK3_STATUS_LEFT;
+ if (where == STATUS_RIGHT)
+ key = KEYC_SECONDCLICK3_STATUS_RIGHT;
+ if (where == STATUS_DEFAULT)
+ key = KEYC_SECONDCLICK3_STATUS_DEFAULT;
+ if (where == BORDER)
+ key = KEYC_SECONDCLICK3_BORDER;
+ break;
+ }
+ break;
case DOUBLE:
switch (MOUSE_BUTTONS(b)) {
case 0: