diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2020-04-13 13:42:36 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2020-04-13 13:42:36 +0000 |
commit | f332e1470fe1588871275b0439ceffa0f7bddf66 (patch) | |
tree | 72e3c46c6b0dc6171677e7ed59e5124346bc8f51 | |
parent | bd8db6c3db9af98dc4b1bcc549263f53e7734bf9 (diff) |
Store a key event not a mouse event in the shared data.
-rw-r--r-- | usr.bin/tmux/cmd-copy-mode.c | 6 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-display-menu.c | 22 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-find.c | 4 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-if-shell.c | 4 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-queue.c | 9 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-resize-pane.c | 6 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-send-keys.c | 4 | ||||
-rw-r--r-- | usr.bin/tmux/format.c | 4 | ||||
-rw-r--r-- | usr.bin/tmux/menu.c | 4 | ||||
-rw-r--r-- | usr.bin/tmux/popup.c | 4 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.h | 4 |
11 files changed, 38 insertions, 33 deletions
diff --git a/usr.bin/tmux/cmd-copy-mode.c b/usr.bin/tmux/cmd-copy-mode.c index 2e9eaa54bf1..39280838ca1 100644 --- a/usr.bin/tmux/cmd-copy-mode.c +++ b/usr.bin/tmux/cmd-copy-mode.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-copy-mode.c,v 1.43 2020/04/13 10:59:58 nicm Exp $ */ +/* $OpenBSD: cmd-copy-mode.c,v 1.44 2020/04/13 13:42:35 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -70,7 +70,7 @@ cmd_copy_mode_exec(struct cmd *self, struct cmdq_item *item) } if (args_has(args, 'M')) { - if ((wp = cmd_mouse_pane(&shared->mouse, &s, NULL)) == NULL) + if ((wp = cmd_mouse_pane(&shared->event.m, &s, NULL)) == NULL) return (CMD_RETURN_NORMAL); if (c == NULL || c->session != s) return (CMD_RETURN_NORMAL); @@ -87,7 +87,7 @@ cmd_copy_mode_exec(struct cmd *self, struct cmdq_item *item) swp = wp; if (!window_pane_set_mode(wp, swp, &window_copy_mode, NULL, args)) { if (args_has(args, 'M')) - window_copy_start_drag(c, &shared->mouse); + window_copy_start_drag(c, &shared->event.m); } if (args_has(args, 'u')) window_copy_pageup(wp, 0); diff --git a/usr.bin/tmux/cmd-display-menu.c b/usr.bin/tmux/cmd-display-menu.c index 3eb989556f9..f1f00592aa6 100644 --- a/usr.bin/tmux/cmd-display-menu.c +++ b/usr.bin/tmux/cmd-display-menu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-display-menu.c,v 1.14 2020/04/13 10:59:58 nicm Exp $ */ +/* $OpenBSD: cmd-display-menu.c,v 1.15 2020/04/13 13:42:35 nicm Exp $ */ /* * Copyright (c) 2019 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -99,9 +99,9 @@ cmd_display_menu_get_position(struct client *c, struct cmdq_item *item, *px = wp->xoff - ox; else *px = 0; - } else if (strcmp(xp, "M") == 0 && shared->mouse.valid) { - if (shared->mouse.x > w / 2) - *px = shared->mouse.x - w / 2; + } else if (strcmp(xp, "M") == 0) { + if (shared->event.m.valid && shared->event.m.x > w / 2) + *px = shared->event.m.x - w / 2; else *px = 0; } else if (strcmp(xp, "W") == 0) { @@ -133,9 +133,12 @@ cmd_display_menu_get_position(struct client *c, struct cmdq_item *item, *py = wp->yoff + wp->sy - oy; else *py = 0; - } else if (strcmp(yp, "M") == 0 && shared->mouse.valid) - *py = shared->mouse.y + h; - else if (strcmp(yp, "S") == 0) { + } else if (strcmp(yp, "M") == 0) { + if (shared->event.m.valid) + *py = shared->event.m.y + h; + else + *py = 0; + } else if (strcmp(yp, "S") == 0) { if (options_get_number(s->options, "status-position") == 0) { if (lines != 0) *py = lines + h; @@ -147,8 +150,7 @@ cmd_display_menu_get_position(struct client *c, struct cmdq_item *item, else *py = c->tty.sy; } - } - else if (strcmp(yp, "W") == 0) { + } else if (strcmp(yp, "W") == 0) { if (options_get_number(s->options, "status-position") == 0) { if (lines != 0) *py = line + 1 + h; @@ -228,7 +230,7 @@ cmd_display_menu_exec(struct cmd *self, struct cmdq_item *item) cmd_display_menu_get_position(c, item, args, &px, &py, menu->width + 4, menu->count + 2); - if (!shared->mouse.valid) + if (!shared->event.m.valid) flags |= MENU_NOMOUSE; if (menu_display(menu, flags, item, px, py, c, target, NULL, NULL) != 0) return (CMD_RETURN_NORMAL); diff --git a/usr.bin/tmux/cmd-find.c b/usr.bin/tmux/cmd-find.c index 4d19d2f8f5b..73a225343dc 100644 --- a/usr.bin/tmux/cmd-find.c +++ b/usr.bin/tmux/cmd-find.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-find.c,v 1.75 2020/04/13 10:59:58 nicm Exp $ */ +/* $OpenBSD: cmd-find.c,v 1.76 2020/04/13 13:42:35 nicm Exp $ */ /* * Copyright (c) 2015 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -982,7 +982,7 @@ cmd_find_target(struct cmd_find_state *fs, struct cmdq_item *item, /* Mouse target is a plain = or {mouse}. */ if (strcmp(target, "=") == 0 || strcmp(target, "{mouse}") == 0) { - m = &cmdq_get_shared(item)->mouse; + m = &cmdq_get_shared(item)->event.m; switch (type) { case CMD_FIND_PANE: fs->wp = cmd_mouse_pane(m, &fs->s, &fs->wl); diff --git a/usr.bin/tmux/cmd-if-shell.c b/usr.bin/tmux/cmd-if-shell.c index 6f307ed063b..5be4a8699ab 100644 --- a/usr.bin/tmux/cmd-if-shell.c +++ b/usr.bin/tmux/cmd-if-shell.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-if-shell.c,v 1.68 2020/04/13 10:59:58 nicm Exp $ */ +/* $OpenBSD: cmd-if-shell.c,v 1.69 2020/04/13 13:42:35 nicm Exp $ */ /* * Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org> @@ -65,7 +65,7 @@ cmd_if_shell_exec(struct cmd *self, struct cmdq_item *item) struct args *args = cmd_get_args(self); struct cmdq_shared *shared = cmdq_get_shared(item); struct cmd_find_state *target = cmdq_get_target(item); - struct mouse_event *m = &shared->mouse; + struct mouse_event *m = &shared->event.m; struct cmd_if_shell_data *cdata; char *shellcmd, *cmd; const char *file; diff --git a/usr.bin/tmux/cmd-queue.c b/usr.bin/tmux/cmd-queue.c index 593aa34f10f..c2261e5a88b 100644 --- a/usr.bin/tmux/cmd-queue.c +++ b/usr.bin/tmux/cmd-queue.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-queue.c,v 1.84 2020/04/13 13:32:09 nicm Exp $ */ +/* $OpenBSD: cmd-queue.c,v 1.85 2020/04/13 13:42:35 nicm Exp $ */ /* * Copyright (c) 2013 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -333,8 +333,11 @@ cmdq_get_command(struct cmd_list *cmdlist, struct cmd_find_state *current, cmd_find_copy_state(&shared->current, current); else cmd_find_clear_state(&shared->current, 0); - if (m != NULL) - memcpy(&shared->mouse, m, sizeof shared->mouse); + if (m != NULL) { + shared->event.key = KEYC_NONE; + memcpy(&shared->event.m, m, + sizeof shared->event.m); + } shared->flags = flags; last_group = group; } diff --git a/usr.bin/tmux/cmd-resize-pane.c b/usr.bin/tmux/cmd-resize-pane.c index ca6a2a2f5b6..c0f1c8b9923 100644 --- a/usr.bin/tmux/cmd-resize-pane.c +++ b/usr.bin/tmux/cmd-resize-pane.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-resize-pane.c,v 1.43 2020/04/13 10:59:58 nicm Exp $ */ +/* $OpenBSD: cmd-resize-pane.c,v 1.44 2020/04/13 13:42:35 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -76,12 +76,12 @@ cmd_resize_pane_exec(struct cmd *self, struct cmdq_item *item) } if (args_has(args, 'M')) { - if (cmd_mouse_window(&shared->mouse, &s) == NULL) + if (cmd_mouse_window(&shared->event.m, &s) == NULL) return (CMD_RETURN_NORMAL); if (c == NULL || c->session != s) return (CMD_RETURN_NORMAL); c->tty.mouse_drag_update = cmd_resize_pane_mouse_update; - cmd_resize_pane_mouse_update(c, &shared->mouse); + cmd_resize_pane_mouse_update(c, &shared->event.m); return (CMD_RETURN_NORMAL); } diff --git a/usr.bin/tmux/cmd-send-keys.c b/usr.bin/tmux/cmd-send-keys.c index a42356bd0e6..d4e72e4d4fb 100644 --- a/usr.bin/tmux/cmd-send-keys.c +++ b/usr.bin/tmux/cmd-send-keys.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-send-keys.c,v 1.56 2020/04/13 10:59:58 nicm Exp $ */ +/* $OpenBSD: cmd-send-keys.c,v 1.57 2020/04/13 13:42:35 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -140,7 +140,7 @@ cmd_send_keys_exec(struct cmd *self, struct cmdq_item *item) struct window_pane *wp = target->wp; struct session *s = target->s; struct winlink *wl = target->wl; - struct mouse_event *m = &shared->mouse; + struct mouse_event *m = &shared->event.m; struct window_mode_entry *wme = TAILQ_FIRST(&wp->modes); int i; key_code key; diff --git a/usr.bin/tmux/format.c b/usr.bin/tmux/format.c index 37dc1e39cf1..dd4b8018850 100644 --- a/usr.bin/tmux/format.c +++ b/usr.bin/tmux/format.c @@ -1,4 +1,4 @@ -/* $OpenBSD: format.c,v 1.237 2020/04/13 10:59:58 nicm Exp $ */ +/* $OpenBSD: format.c,v 1.238 2020/04/13 13:42:35 nicm Exp $ */ /* * Copyright (c) 2011 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -1133,7 +1133,7 @@ format_create_add_item(struct format_tree *ft, struct cmdq_item *item) if (shared == NULL) return; - m = &shared->mouse; + m = &shared->event.m; if (m->valid && ((wp = cmd_mouse_pane(m, NULL, NULL)) != NULL)) { format_add(ft, "mouse_pane", "%%%u", wp->id); if (cmd_mouse_at(wp, m, &x, &y, 0) == 0) { diff --git a/usr.bin/tmux/menu.c b/usr.bin/tmux/menu.c index 41262c32bff..5c60f6dbb43 100644 --- a/usr.bin/tmux/menu.c +++ b/usr.bin/tmux/menu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: menu.c,v 1.16 2020/04/13 10:59:58 nicm Exp $ */ +/* $OpenBSD: menu.c,v 1.17 2020/04/13 13:42:35 nicm Exp $ */ /* * Copyright (c) 2019 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -282,7 +282,7 @@ chosen: break; case CMD_PARSE_SUCCESS: if (md->item != NULL) - m = &cmdq_get_shared(md->item)->mouse; + m = &cmdq_get_shared(md->item)->event.m; else m = NULL; new_item = cmdq_get_command(pr->cmdlist, &md->fs, m, 0); diff --git a/usr.bin/tmux/popup.c b/usr.bin/tmux/popup.c index ec331d8a9d5..1903ca5425d 100644 --- a/usr.bin/tmux/popup.c +++ b/usr.bin/tmux/popup.c @@ -1,4 +1,4 @@ -/* $OpenBSD: popup.c,v 1.8 2020/04/13 10:59:59 nicm Exp $ */ +/* $OpenBSD: popup.c,v 1.9 2020/04/13 13:42:35 nicm Exp $ */ /* * Copyright (c) 2020 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -305,7 +305,7 @@ popup_key_cb(struct client *c, struct key_event *event) break; case CMD_PARSE_SUCCESS: if (pd->item != NULL) - m = &cmdq_get_shared(pd->item)->mouse; + m = &cmdq_get_shared(pd->item)->event.m; else m = NULL; new_item = cmdq_get_command(pr->cmdlist, fs, m, 0); diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 3b8d1ec4a91..380a88605f3 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.983 2020/04/13 13:32:09 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.984 2020/04/13 13:42:35 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -1389,7 +1389,7 @@ struct cmdq_shared { struct format_tree *formats; - struct mouse_event mouse; + struct key_event event; struct cmd_find_state current; }; |