summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/server-client.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2016-03-01 12:04:43 +0000
committernicm <nicm@openbsd.org>2016-03-01 12:04:43 +0000
commita025c48d73a38137dce7835391b0beabe12e03f8 (patch)
tree7b3286faa183192dda94510d3bb7113148320719 /usr.bin/tmux/server-client.c
parentRemove unused variables, from Michal Mazurek. (diff)
downloadwireguard-openbsd-a025c48d73a38137dce7835391b0beabe12e03f8.tar.xz
wireguard-openbsd-a025c48d73a38137dce7835391b0beabe12e03f8.zip
When a mouse drag is finished, fire a MouseUp key press, instead of
doing the drag end in code. From Stephen Coakley.
Diffstat (limited to 'usr.bin/tmux/server-client.c')
-rw-r--r--usr.bin/tmux/server-client.c44
1 files changed, 41 insertions, 3 deletions
diff --git a/usr.bin/tmux/server-client.c b/usr.bin/tmux/server-client.c
index af332399e42..03a679f8f5b 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.181 2016/01/19 15:59:12 nicm Exp $ */
+/* $OpenBSD: server-client.c,v 1.182 2016/03/01 12:04:43 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -384,8 +384,42 @@ server_client_check_mouse(struct client *c)
c->tty.mouse_drag_update = NULL;
c->tty.mouse_drag_release = NULL;
+ /*
+ * End a mouse drag by passing a MouseUp key corresponding to
+ * the button that started the drag.
+ */
+ switch (c->tty.mouse_drag_flag) {
+ case 1:
+ if (where == PANE)
+ key = KEYC_MOUSEUP1_PANE;
+ if (where == STATUS)
+ key = KEYC_MOUSEUP1_STATUS;
+ if (where == BORDER)
+ key = KEYC_MOUSEUP1_BORDER;
+ break;
+ case 2:
+ if (where == PANE)
+ key = KEYC_MOUSEUP2_PANE;
+ if (where == STATUS)
+ key = KEYC_MOUSEUP2_STATUS;
+ if (where == BORDER)
+ key = KEYC_MOUSEUP2_BORDER;
+ break;
+ case 3:
+ if (where == PANE)
+ key = KEYC_MOUSEUP3_PANE;
+ if (where == STATUS)
+ key = KEYC_MOUSEUP3_STATUS;
+ if (where == BORDER)
+ key = KEYC_MOUSEUP3_BORDER;
+ break;
+ default:
+ key = KEYC_MOUSE;
+ break;
+ }
c->tty.mouse_drag_flag = 0;
- return (KEYC_MOUSE); /* not a key, but still may want to pass */
+
+ return (key);
}
/* Convert to a key binding. */
@@ -425,7 +459,11 @@ server_client_check_mouse(struct client *c)
}
}
- c->tty.mouse_drag_flag = 1;
+ /*
+ * Begin a drag by setting the flag to a non-zero value that
+ * corresponds to the mouse button in use.
+ */
+ c->tty.mouse_drag_flag = MOUSE_BUTTONS(b) + 1;
break;
case WHEEL:
if (MOUSE_BUTTONS(b) == MOUSE_WHEEL_UP) {