mirror of
https://github.com/tmux/tmux.git
synced 2025-01-05 23:38:48 +00:00
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.
This commit is contained in:
parent
3bbd66c013
commit
01b3bb8e2c
@ -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),
|
||||
|
@ -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:
|
||||
|
9
tmux.1
9
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
|
||||
|
3
tmux.h
3
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),
|
||||
|
Loading…
Reference in New Issue
Block a user