summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2016-11-24 13:46:50 +0000
committernicm <nicm@openbsd.org>2016-11-24 13:46:50 +0000
commit3cf6583d5c1f12cb6c308bfb1f67b451ee5c2c6d (patch)
treea1fe6b841d44822a56d59d872377e477e0d316ca
parentMake the selection able to exist independent of the cursor position, so (diff)
downloadwireguard-openbsd-3cf6583d5c1f12cb6c308bfb1f67b451ee5c2c6d.tar.xz
wireguard-openbsd-3cf6583d5c1f12cb6c308bfb1f67b451ee5c2c6d.zip
Fix so that we work out the right pane from mouse events - we were doing
so too early, before the mouse event was necessarily valid, so could end up using the pane from the previous mouse event, or the active pane. It is important that we use the right pane now that different panes can have different key tables (for copy mode). Fixes problem reported by Greg Hurrell.
-rw-r--r--usr.bin/tmux/key-bindings.c24
-rw-r--r--usr.bin/tmux/server-client.c23
2 files changed, 28 insertions, 19 deletions
diff --git a/usr.bin/tmux/key-bindings.c b/usr.bin/tmux/key-bindings.c
index 56816fc4393..3f74e5f9daa 100644
--- a/usr.bin/tmux/key-bindings.c
+++ b/usr.bin/tmux/key-bindings.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: key-bindings.c,v 1.65 2016/11/23 17:01:24 nicm Exp $ */
+/* $OpenBSD: key-bindings.c,v 1.66 2016/11/24 13:46:50 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -259,12 +259,13 @@ key_bindings_init(void)
"bind -Tcopy-mode n send -X search-again",
"bind -Tcopy-mode q send -X cancel",
"bind -Tcopy-mode t command-prompt -1p'jump to forward' \"send -X jump-to-forward \\\"%%%\\\"\"",
- "bind -Tcopy-mode MouseDrag1Pane send -X begin-selection",
+ "bind -Tcopy-mode MouseDown1Pane select-pane",
+ "bind -Tcopy-mode MouseDrag1Pane select-pane\\; send -X begin-selection",
"bind -Tcopy-mode MouseDragEnd1Pane send -X copy-selection-and-cancel",
- "bind -Tcopy-mode WheelUpPane send -N5 -X scroll-up",
- "bind -Tcopy-mode WheelDownPane send -N5 -X scroll-down",
- "bind -Tcopy-mode DoubleClick1Pane send -X select-word",
- "bind -Tcopy-mode TripleClick1Pane send -X select-line",
+ "bind -Tcopy-mode WheelUpPane select-pane\\; send -N5 -X scroll-up",
+ "bind -Tcopy-mode WheelDownPane select-pane\\; send -N5 -X scroll-down",
+ "bind -Tcopy-mode DoubleClick1Pane select-pane\\; send -X select-word",
+ "bind -Tcopy-mode TripleClick1Pane select-pane\\; send -X select-line",
"bind -Tcopy-mode NPage send -X page-down",
"bind -Tcopy-mode PPage send -X page-up",
"bind -Tcopy-mode Up send -X cursor-up",
@@ -356,12 +357,13 @@ key_bindings_init(void)
"bind -Tcopy-mode-vi w send -X next-word",
"bind -Tcopy-mode-vi { send -X previous-paragraph",
"bind -Tcopy-mode-vi } send -X next-paragraph",
- "bind -Tcopy-mode-vi MouseDrag1Pane send -X begin-selection",
+ "bind -Tcopy-mode-vi MouseDown1Pane select-pane",
+ "bind -Tcopy-mode-vi MouseDrag1Pane select-pane\\; send -X begin-selection",
"bind -Tcopy-mode-vi MouseDragEnd1Pane send -X copy-selection-and-cancel",
- "bind -Tcopy-mode-vi WheelUpPane send -N5 -X scroll-up",
- "bind -Tcopy-mode-vi WheelDownPane send -N5 -X scroll-down",
- "bind -Tcopy-mode-vi DoubleClick1Pane send -X select-word",
- "bind -Tcopy-mode-vi TripleClick1Pane send -X select-line",
+ "bind -Tcopy-mode-vi WheelUpPane select-pane\\; send -N5 -X scroll-up",
+ "bind -Tcopy-mode-vi WheelDownPane select-pane\\; send -N5 -X scroll-down",
+ "bind -Tcopy-mode-vi DoubleClick1Pane select-pane\\; send -X select-word",
+ "bind -Tcopy-mode-vi TripleClick1Pane select-pane\\; send -X select-line",
"bind -Tcopy-mode-vi BSpace send -X cursor-left",
"bind -Tcopy-mode-vi NPage send -X page-down",
"bind -Tcopy-mode-vi PPage send -X page-up",
diff --git a/usr.bin/tmux/server-client.c b/usr.bin/tmux/server-client.c
index f2be6e1ffba..e57f0b1a78b 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.201 2016/11/23 17:01:24 nicm Exp $ */
+/* $OpenBSD: server-client.c,v 1.202 2016/11/24 13:46:50 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -698,10 +698,6 @@ server_client_handle_key(struct client *c, key_code key)
if (s == NULL || (c->flags & (CLIENT_DEAD|CLIENT_SUSPENDED)) != 0)
return;
w = s->curw->window;
- if (KEYC_IS_MOUSE(key))
- wp = cmd_mouse_pane(m, NULL, NULL);
- else
- wp = w->active;
/* Update the activity timer. */
if (gettimeofday(&c->activity_time, NULL) != 0)
@@ -742,12 +738,19 @@ server_client_handle_key(struct client *c, key_code key)
m->valid = 1;
m->key = key;
-
- if (!options_get_number(s->options, "mouse"))
- goto forward;
} else
m->valid = 0;
+ /* Find affected pane. */
+ if (KEYC_IS_MOUSE(key) && m->valid)
+ wp = cmd_mouse_pane(m, NULL, NULL);
+ else
+ wp = w->active;
+
+ /* Forward mouse keys if disabled. */
+ if (key == KEYC_MOUSE && !options_get_number(s->options, "mouse"))
+ goto forward;
+
/* Treat everything as a regular key when pasting is detected. */
if (!KEYC_IS_MOUSE(key) && server_client_assume_paste(s))
goto forward;
@@ -764,6 +767,10 @@ retry:
table = c->keytable;
else
table = key_bindings_get_table(name, 1);
+ if (wp == NULL)
+ log_debug("key table %s (no pane)", table->name);
+ else
+ log_debug("key table %s (pane %%%u)", table->name, wp->id);
/* Try to see if there is a key binding in the current table. */
bd_find.key = key;