mirror of
https://github.com/tmux/tmux.git
synced 2026-10-11 21:14:21 +00:00
Add a mouse binding for empty areas of the window so C-Drag works on
them as well.
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
/* $OpenBSD: key-bindings.c,v 1.188 2026/07/13 16:30:28 nicm Exp $ */
|
/* $OpenBSD: key-bindings.c,v 1.189 2026/07/15 10:38:31 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
|
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
@@ -503,6 +503,7 @@ key_bindings_init(void)
|
|||||||
/* Mouse button 1 drag on pane. */
|
/* Mouse button 1 drag on pane. */
|
||||||
"bind -n MouseDrag1Pane { if -F '#{||:#{pane_in_mode},#{mouse_any_flag}}' { send -M } { copy-mode -M } }",
|
"bind -n MouseDrag1Pane { if -F '#{||:#{pane_in_mode},#{mouse_any_flag}}' { send -M } { copy-mode -M } }",
|
||||||
"bind -n C-MouseDrag1Pane { new-pane -M }",
|
"bind -n C-MouseDrag1Pane { new-pane -M }",
|
||||||
|
"bind -n C-MouseDrag1Empty { new-pane -M }",
|
||||||
"bind -n M-MouseDrag1Pane { move-pane -M }",
|
"bind -n M-MouseDrag1Pane { move-pane -M }",
|
||||||
|
|
||||||
/* Mouse wheel up on pane. */
|
/* Mouse wheel up on pane. */
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* $OpenBSD: server-client.c,v 1.491 2026/07/14 19:07:03 nicm Exp $ */
|
/* $OpenBSD: server-client.c,v 1.492 2026/07/15 10:38:31 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
|
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
@@ -1033,46 +1033,46 @@ have_event:
|
|||||||
* Not on status line. Adjust position and check for border, pane, or
|
* Not on status line. Adjust position and check for border, pane, or
|
||||||
* scrollbar.
|
* scrollbar.
|
||||||
*/
|
*/
|
||||||
if (loc == KEYC_MOUSE_LOCATION_NOWHERE) {
|
if (loc == KEYC_MOUSE_LOCATION_NOWHERE && c->tty.mouse_scrolling_flag) {
|
||||||
if (c->tty.mouse_scrolling_flag) {
|
if (lwp != NULL) {
|
||||||
if (lwp != NULL) {
|
loc = KEYC_MOUSE_LOCATION_SCROLLBAR_SLIDER;
|
||||||
loc = KEYC_MOUSE_LOCATION_SCROLLBAR_SLIDER;
|
m->wp = lwp->id;
|
||||||
m->wp = lwp->id;
|
m->w = lwp->window->id;
|
||||||
m->w = lwp->window->id;
|
}
|
||||||
}
|
} else if (loc == KEYC_MOUSE_LOCATION_NOWHERE) {
|
||||||
|
px = x;
|
||||||
|
if (m->statusat == 0 && y >= m->statuslines)
|
||||||
|
py = y - m->statuslines;
|
||||||
|
else if (m->statusat > 0 && y >= (u_int)m->statusat)
|
||||||
|
py = m->statusat - 1;
|
||||||
|
else
|
||||||
|
py = y;
|
||||||
|
|
||||||
|
tty_window_offset(&c->tty, &m->ox, &m->oy, &sx, &sy);
|
||||||
|
log_debug("mouse window @%u at %u,%u (%ux%u)", w->id, m->ox,
|
||||||
|
m->oy, sx, sy);
|
||||||
|
if (px > sx || py > sy) {
|
||||||
|
server_client_update_scrollbar_hover(c, type, -1, -1);
|
||||||
|
return (KEYC_UNKNOWN);
|
||||||
|
}
|
||||||
|
px = px + m->ox;
|
||||||
|
py = py + m->oy;
|
||||||
|
server_client_update_scrollbar_hover(c, type, px, py);
|
||||||
|
|
||||||
|
if (type == KEYC_TYPE_MOUSEDRAG && lwp != NULL) {
|
||||||
|
/* Use pane from last mouse event. */
|
||||||
|
wp = lwp;
|
||||||
|
} else {
|
||||||
|
/* Try inside the pane. */
|
||||||
|
wp = window_get_active_at(w, px, py);
|
||||||
|
}
|
||||||
|
if (wp == NULL) {
|
||||||
|
loc = KEYC_MOUSE_LOCATION_EMPTY;
|
||||||
|
m->w = w->id;
|
||||||
|
log_debug("mouse %u,%u on empty area", x, y);
|
||||||
} else {
|
} else {
|
||||||
px = x;
|
|
||||||
if (m->statusat == 0 && y >= m->statuslines)
|
|
||||||
py = y - m->statuslines;
|
|
||||||
else if (m->statusat > 0 && y >= (u_int)m->statusat)
|
|
||||||
py = m->statusat - 1;
|
|
||||||
else
|
|
||||||
py = y;
|
|
||||||
|
|
||||||
tty_window_offset(&c->tty, &m->ox, &m->oy, &sx, &sy);
|
|
||||||
log_debug("mouse window @%u at %u,%u (%ux%u)",
|
|
||||||
w->id, m->ox, m->oy, sx, sy);
|
|
||||||
if (px > sx || py > sy) {
|
|
||||||
server_client_update_scrollbar_hover(c, type,
|
|
||||||
-1, -1);
|
|
||||||
return (KEYC_UNKNOWN);
|
|
||||||
}
|
|
||||||
px = px + m->ox;
|
|
||||||
py = py + m->oy;
|
|
||||||
server_client_update_scrollbar_hover(c, type, px, py);
|
|
||||||
|
|
||||||
if (type == KEYC_TYPE_MOUSEDRAG && lwp != NULL) {
|
|
||||||
/* Use pane from last mouse event. */
|
|
||||||
wp = lwp;
|
|
||||||
} else {
|
|
||||||
/* Try inside the pane. */
|
|
||||||
wp = window_get_active_at(w, px, py);
|
|
||||||
}
|
|
||||||
if (wp == NULL)
|
|
||||||
return (KEYC_UNKNOWN);
|
|
||||||
loc = server_client_check_mouse_in_pane(wp, px, py,
|
loc = server_client_check_mouse_in_pane(wp, px, py,
|
||||||
&sl_mpos);
|
&sl_mpos);
|
||||||
|
|
||||||
if (loc == KEYC_MOUSE_LOCATION_PANE) {
|
if (loc == KEYC_MOUSE_LOCATION_PANE) {
|
||||||
log_debug("mouse %u,%u on pane %%%u", x, y,
|
log_debug("mouse %u,%u on pane %%%u", x, y,
|
||||||
wp->id);
|
wp->id);
|
||||||
|
|||||||
5
tmux.1
5
tmux.1
@@ -1,4 +1,4 @@
|
|||||||
.\" $OpenBSD: tmux.1,v 1.1140 2026/07/14 17:17:18 nicm Exp $
|
.\" $OpenBSD: tmux.1,v 1.1141 2026/07/15 10:38:31 nicm Exp $
|
||||||
.\"
|
.\"
|
||||||
.\" Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
|
.\" Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
.\"
|
.\"
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
.\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
.\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||||
.\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
.\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
.\"
|
.\"
|
||||||
.Dd $Mdocdate: July 14 2026 $
|
.Dd $Mdocdate: July 15 2026 $
|
||||||
.Dt TMUX 1
|
.Dt TMUX 1
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@@ -6618,6 +6618,7 @@ and a location suffix, one of the following:
|
|||||||
.It Li "ScrollbarSlider" Ta "the scrollbar slider"
|
.It Li "ScrollbarSlider" Ta "the scrollbar slider"
|
||||||
.It Li "ScrollbarUp" Ta "above the scrollbar slider"
|
.It Li "ScrollbarUp" Ta "above the scrollbar slider"
|
||||||
.It Li "ScrollbarDown" Ta "below the scrollbar slider"
|
.It Li "ScrollbarDown" Ta "below the scrollbar slider"
|
||||||
|
.It Li "Empty" Ta "empty space in the window"
|
||||||
.It Li "ControlN" Ta "on control range N"
|
.It Li "ControlN" Ta "on control range N"
|
||||||
.El
|
.El
|
||||||
.Pp
|
.Pp
|
||||||
|
|||||||
5
tmux.h
5
tmux.h
@@ -1,4 +1,4 @@
|
|||||||
/* $OpenBSD: tmux.h,v 1.1404 2026/07/14 19:07:03 nicm Exp $ */
|
/* $OpenBSD: tmux.h,v 1.1405 2026/07/15 10:38:31 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
|
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||||
@@ -181,6 +181,7 @@ enum key_code_mouse_location {
|
|||||||
KEYC_MOUSE_LOCATION_SCROLLBAR_UP,
|
KEYC_MOUSE_LOCATION_SCROLLBAR_UP,
|
||||||
KEYC_MOUSE_LOCATION_SCROLLBAR_SLIDER,
|
KEYC_MOUSE_LOCATION_SCROLLBAR_SLIDER,
|
||||||
KEYC_MOUSE_LOCATION_SCROLLBAR_DOWN,
|
KEYC_MOUSE_LOCATION_SCROLLBAR_DOWN,
|
||||||
|
KEYC_MOUSE_LOCATION_EMPTY,
|
||||||
KEYC_MOUSE_LOCATION_CONTROL0, /* keep order */
|
KEYC_MOUSE_LOCATION_CONTROL0, /* keep order */
|
||||||
KEYC_MOUSE_LOCATION_CONTROL1,
|
KEYC_MOUSE_LOCATION_CONTROL1,
|
||||||
KEYC_MOUSE_LOCATION_CONTROL2,
|
KEYC_MOUSE_LOCATION_CONTROL2,
|
||||||
@@ -237,6 +238,7 @@ enum key_code_mouse_location {
|
|||||||
KEYC_MOUSE_KEY(KEYC_ ## t, KEYC_TYPE_ ## t, SCROLLBAR_UP), \
|
KEYC_MOUSE_KEY(KEYC_ ## t, KEYC_TYPE_ ## t, SCROLLBAR_UP), \
|
||||||
KEYC_MOUSE_KEY(KEYC_ ## t, KEYC_TYPE_ ## t, SCROLLBAR_SLIDER), \
|
KEYC_MOUSE_KEY(KEYC_ ## t, KEYC_TYPE_ ## t, SCROLLBAR_SLIDER), \
|
||||||
KEYC_MOUSE_KEY(KEYC_ ## t, KEYC_TYPE_ ## t, SCROLLBAR_DOWN), \
|
KEYC_MOUSE_KEY(KEYC_ ## t, KEYC_TYPE_ ## t, SCROLLBAR_DOWN), \
|
||||||
|
KEYC_MOUSE_KEY(KEYC_ ## t, KEYC_TYPE_ ## t, EMPTY), \
|
||||||
KEYC_MOUSE_KEY(KEYC_ ## t, KEYC_TYPE_ ## t, CONTROL0), \
|
KEYC_MOUSE_KEY(KEYC_ ## t, KEYC_TYPE_ ## t, CONTROL0), \
|
||||||
KEYC_MOUSE_KEY(KEYC_ ## t, KEYC_TYPE_ ## t, CONTROL1), \
|
KEYC_MOUSE_KEY(KEYC_ ## t, KEYC_TYPE_ ## t, CONTROL1), \
|
||||||
KEYC_MOUSE_KEY(KEYC_ ## t, KEYC_TYPE_ ## t, CONTROL2), \
|
KEYC_MOUSE_KEY(KEYC_ ## t, KEYC_TYPE_ ## t, CONTROL2), \
|
||||||
@@ -271,6 +273,7 @@ enum key_code_mouse_location {
|
|||||||
{ #s "ScrollbarUp", KEYC_ ## name ## _SCROLLBAR_UP }, \
|
{ #s "ScrollbarUp", KEYC_ ## name ## _SCROLLBAR_UP }, \
|
||||||
{ #s "ScrollbarSlider", KEYC_ ## name ## _SCROLLBAR_SLIDER }, \
|
{ #s "ScrollbarSlider", KEYC_ ## name ## _SCROLLBAR_SLIDER }, \
|
||||||
{ #s "ScrollbarDown", KEYC_ ## name ## _SCROLLBAR_DOWN }, \
|
{ #s "ScrollbarDown", KEYC_ ## name ## _SCROLLBAR_DOWN }, \
|
||||||
|
{ #s "Empty", KEYC_ ## name ## _EMPTY }, \
|
||||||
{ #s "Border", KEYC_ ## name ## _BORDER }, \
|
{ #s "Border", KEYC_ ## name ## _BORDER }, \
|
||||||
{ #s "Control0", KEYC_ ## name ## _CONTROL0 }, \
|
{ #s "Control0", KEYC_ ## name ## _CONTROL0 }, \
|
||||||
{ #s "Control1", KEYC_ ## name ## _CONTROL1 }, \
|
{ #s "Control1", KEYC_ ## name ## _CONTROL1 }, \
|
||||||
|
|||||||
Reference in New Issue
Block a user