From 01b3bb8e2c695a7a32a332758e5a8f4a650fc98c Mon Sep 17 00:00:00 2001 From: nicm Date: Tue, 31 Mar 2020 11:38:35 +0000 Subject: [PATCH 1/2] 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. --- key-string.c | 3 +++ server-client.c | 63 ++++++++++++++++++++++++++++++++++++++++++------- tmux.1 | 9 +++++++ tmux.h | 3 +++ 4 files changed, 70 insertions(+), 8 deletions(-) diff --git a/key-string.c b/key-string.c index 38e5b8a7..76ee4fbe 100644 --- a/key-string.c +++ b/key-string.c @@ -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/server-client.c b/server-client.c index 75e80c81..aa174d4d 100644 --- a/server-client.c +++ b/server-client.c @@ -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/tmux.1 b/tmux.1 index 5ee1a5aa..e370b4b1 100644 --- a/tmux.1 +++ b/tmux.1 @@ -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/tmux.h b/tmux.h index 2e6ef0c1..3023376c 100644 --- a/tmux.h +++ b/tmux.h @@ -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), From 2a4714e76b3a85b3391b05413f36623bcb1493f9 Mon Sep 17 00:00:00 2001 From: nicm Date: Tue, 31 Mar 2020 11:58:05 +0000 Subject: [PATCH 2/2] Add session_path from Chris Ruegge in GitHub issue 2142. --- format.c | 1 + tmux.1 | 1 + 2 files changed, 2 insertions(+) diff --git a/format.c b/format.c index 15347e18..815be8da 100644 --- a/format.c +++ b/format.c @@ -2477,6 +2477,7 @@ format_defaults_session(struct format_tree *ft, struct session *s) ft->s = s; format_add(ft, "session_name", "%s", s->name); + format_add(ft, "session_path", "%s", s->cwd); format_add(ft, "session_windows", "%u", winlink_count(&s->windows)); format_add(ft, "session_id", "$%u", s->id); diff --git a/tmux.1 b/tmux.1 index e370b4b1..667242db 100644 --- a/tmux.1 +++ b/tmux.1 @@ -4422,6 +4422,7 @@ The following variables are available, where appropriate: .It Li "session_last_attached" Ta "" Ta "Time session last attached" .It Li "session_many_attached" Ta "" Ta "1 if multiple clients attached" .It Li "session_name" Ta "#S" Ta "Name of session" +.It Li "session_path" Ta "" Ta "Working directory of session" .It Li "session_stack" Ta "" Ta "Window indexes in most recent order" .It Li "session_windows" Ta "" Ta "Number of windows in session" .It Li "socket_path" Ta "" Ta "Server socket path"