summaryrefslogtreecommitdiff
path: root/usr.bin/tmux
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2020-03-31 11:38:36 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2020-03-31 11:38:36 +0000
commit2c4c8b1883be9ac4deb0656393256bc901aebdc9 (patch)
tree4a69d140f69d248c88126305fed1dd90664277cf /usr.bin/tmux
parent08b48a946e0f1618af828e46c6c00b2150573cb3 (diff)
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')
-rw-r--r--usr.bin/tmux/key-string.c5
-rw-r--r--usr.bin/tmux/server-client.c65
-rw-r--r--usr.bin/tmux/tmux.113
-rw-r--r--usr.bin/tmux/tmux.h5
4 files changed, 75 insertions, 13 deletions
diff --git a/usr.bin/tmux/key-string.c b/usr.bin/tmux/key-string.c
index 99a29aba806..c78b19bff64 100644
--- a/usr.bin/tmux/key-string.c
+++ b/usr.bin/tmux/key-string.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: key-string.c,v 1.54 2020/03/15 20:35:52 nicm Exp $ */
+/* $OpenBSD: key-string.c,v 1.55 2020/03/31 11:38:35 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -100,6 +100,9 @@ static const struct {
KEYC_MOUSE_STRING(MOUSEDRAGEND3, MouseDragEnd3),
KEYC_MOUSE_STRING(WHEELUP, WheelUp),
KEYC_MOUSE_STRING(WHEELDOWN, WheelDown),
+ KEYC_MOUSE_STRING(SECONDCLICK1, SecondClick1),
+ KEYC_MOUSE_STRING(SECONDCLICK2, SecondClick2),
+ KEYC_MOUSE_STRING(SECONDCLICK3, SecondClick3),
KEYC_MOUSE_STRING(DOUBLECLICK1, DoubleClick1),
KEYC_MOUSE_STRING(DOUBLECLICK2, DoubleClick2),
KEYC_MOUSE_STRING(DOUBLECLICK3, DoubleClick3),
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:
diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1
index cc2db2e9ed7..a785cb5a316 100644
--- a/usr.bin/tmux/tmux.1
+++ b/usr.bin/tmux/tmux.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: tmux.1,v 1.723 2020/03/28 09:51:12 nicm Exp $
+.\" $OpenBSD: tmux.1,v 1.724 2020/03/31 11:38:35 nicm Exp $
.\"
.\" Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
.\"
@@ -14,7 +14,7 @@
.\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
.\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: March 28 2020 $
+.Dd $Mdocdate: March 31 2020 $
.Dt TMUX 1
.Os
.Sh NAME
@@ -3982,10 +3982,19 @@ The following mouse events are available:
.It Li "MouseDown1" Ta "MouseUp1" Ta "MouseDrag1" Ta "MouseDragEnd1"
.It Li "MouseDown2" Ta "MouseUp2" Ta "MouseDrag2" Ta "MouseDragEnd2"
.It Li "MouseDown3" Ta "MouseUp3" Ta "MouseDrag3" Ta "MouseDragEnd3"
+.It Li "SecondClick1" Ta "SecondClick2" Ta "SecondClick3"
.It Li "DoubleClick1" Ta "DoubleClick2" Ta "DoubleClick3"
.It Li "TripleClick1" Ta "TripleClick2" Ta "TripleClick3"
.El
.Pp
+The
+.Ql SecondClick
+events are fired for the second click of a double click, even if there may be a
+third click which will fire
+.Ql TripleClick
+instead of
+.Ql DoubleClick .
+.Pp
Each should be suffixed with a location, for example
.Ql MouseDown1Status .
.Pp
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index 36a0bb87b08..f3ec8feb201 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.969 2020/03/31 07:00:34 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.970 2020/03/31 11:38:35 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -182,6 +182,9 @@ enum {
KEYC_MOUSE_KEY(MOUSEDRAGEND3),
KEYC_MOUSE_KEY(WHEELUP),
KEYC_MOUSE_KEY(WHEELDOWN),
+ KEYC_MOUSE_KEY(SECONDCLICK1),
+ KEYC_MOUSE_KEY(SECONDCLICK2),
+ KEYC_MOUSE_KEY(SECONDCLICK3),
KEYC_MOUSE_KEY(DOUBLECLICK1),
KEYC_MOUSE_KEY(DOUBLECLICK2),
KEYC_MOUSE_KEY(DOUBLECLICK3),