summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/popup.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2020-04-01 09:05:28 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2020-04-01 09:05:28 +0000
commitf810195db411535c08af8d4a8d73e4a2239f2043 (patch)
tree74320d82148d42b72a0b3f27389efa04d6f38076 /usr.bin/tmux/popup.c
parent6b5b9a69f57b53fdb7035135ad7b9ceaf9e4b97d (diff)
Support mouse in popups.
Diffstat (limited to 'usr.bin/tmux/popup.c')
-rw-r--r--usr.bin/tmux/popup.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/usr.bin/tmux/popup.c b/usr.bin/tmux/popup.c
index 71cc853d9bc..e574b833f02 100644
--- a/usr.bin/tmux/popup.c
+++ b/usr.bin/tmux/popup.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: popup.c,v 1.5 2020/03/31 06:35:38 nicm Exp $ */
+/* $OpenBSD: popup.c,v 1.6 2020/04/01 09:05:27 nicm Exp $ */
/*
* Copyright (c) 2020 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -225,7 +225,8 @@ popup_key_cb(struct client *c, struct key_event *event)
struct cmdq_item *new_item;
struct cmd_parse_result *pr;
struct format_tree *ft;
- const char *cmd;
+ const char *cmd, *buf;
+ size_t len;
if (KEYC_IS_MOUSE(event->key)) {
if (pd->dragging != OFF) {
@@ -258,14 +259,20 @@ popup_key_cb(struct client *c, struct key_event *event)
}
if (pd->ictx != NULL && (pd->flags & POPUP_WRITEKEYS)) {
- if (KEYC_IS_MOUSE(event->key))
- return (0);
if (((pd->flags & (POPUP_CLOSEEXIT|POPUP_CLOSEEXITZERO)) == 0 ||
pd->job == NULL) &&
(event->key == '\033' || event->key == '\003'))
return (1);
if (pd->job == NULL)
return (0);
+ if (KEYC_IS_MOUSE(event->key)) {
+ /* Must be inside, checked already. */
+ if (!input_key_get_mouse(&pd->s, m, m->x - pd->px,
+ m->y - pd->py, &buf, &len))
+ return (0);
+ bufferevent_write(job_get_event(pd->job), buf, len);
+ return (0);
+ }
input_key(NULL, &pd->s, job_get_event(pd->job), event->key);
return (0);
}