diff options
author | 2019-05-03 14:51:30 +0000 | |
---|---|---|
committer | 2019-05-03 14:51:30 +0000 | |
commit | a88e9db61fa9942c81d04485f92b457a6c8206a3 (patch) | |
tree | 7dec80202515a2e42add396030830b58b880ce83 /usr.bin/tmux/server-client.c | |
parent | typo in previous (diff) | |
download | wireguard-openbsd-a88e9db61fa9942c81d04485f92b457a6c8206a3.tar.xz wireguard-openbsd-a88e9db61fa9942c81d04485f92b457a6c8206a3.zip |
Instead of processing keys all together, put them up on the client
command queue so they are ordered correctly with the commands that they
execute.
Diffstat (limited to 'usr.bin/tmux/server-client.c')
-rw-r--r-- | usr.bin/tmux/server-client.c | 65 |
1 files changed, 40 insertions, 25 deletions
diff --git a/usr.bin/tmux/server-client.c b/usr.bin/tmux/server-client.c index 1d4c9060056..26357a255ea 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.275 2019/04/18 10:11:52 nicm Exp $ */ +/* $OpenBSD: server-client.c,v 1.276 2019/05/03 14:51:30 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -35,7 +35,7 @@ static void server_client_free(int, short, void *); static void server_client_check_focus(struct window_pane *); static void server_client_check_resize(struct window_pane *); -static key_code server_client_check_mouse(struct client *); +static key_code server_client_check_mouse(struct client *, struct key_event *); static void server_client_repeat_timer(int, short, void *); static void server_client_click_timer(int, short, void *); static void server_client_check_exit(struct client *); @@ -407,10 +407,10 @@ server_client_exec(struct client *c, const char *cmd) /* Check for mouse keys. */ static key_code -server_client_check_mouse(struct client *c) +server_client_check_mouse(struct client *c, struct key_event *event) { + struct mouse_event *m = &event->m; struct session *s = c->session; - struct mouse_event *m = &c->tty.mouse; struct winlink *wl; struct window_pane *wp; u_int x, y, b, sx, sy, px, py; @@ -419,7 +419,13 @@ server_client_check_mouse(struct client *c) struct timeval tv; struct style_range *sr; enum { NOTYPE, MOVE, DOWN, UP, DRAG, WHEEL, DOUBLE, TRIPLE } type; - enum { NOWHERE, PANE, STATUS, STATUS_LEFT, STATUS_RIGHT, STATUS_DEFAULT, BORDER } where; + enum { NOWHERE, + PANE, + STATUS, + STATUS_LEFT, + STATUS_RIGHT, + STATUS_DEFAULT, + BORDER } where; type = NOTYPE; where = NOWHERE; @@ -976,11 +982,17 @@ server_client_assume_paste(struct session *s) return (0); } -/* Handle data key input from client. */ -void -server_client_handle_key(struct client *c, key_code key) +/* + * Handle data key input from client. This owns and can modify the key event it + * is given and is responsible for freeing it. + */ +enum cmd_retval +server_client_key_callback(struct cmdq_item *item, void *data) { - struct mouse_event *m = &c->tty.mouse; + struct client *c = item->client; + struct key_event *event = data; + key_code key = event->key; + struct mouse_event *m = &event->m; struct session *s = c->session; struct winlink *wl; struct window *w; @@ -995,7 +1007,7 @@ server_client_handle_key(struct client *c, key_code key) /* Check the client is good to accept input. */ if (s == NULL || (c->flags & (CLIENT_DEAD|CLIENT_SUSPENDED)) != 0) - return; + goto out; wl = s->curw; w = wl->window; @@ -1007,11 +1019,11 @@ server_client_handle_key(struct client *c, key_code key) /* Number keys jump to pane in identify mode. */ if (c->flags & CLIENT_IDENTIFY && key >= '0' && key <= '9') { if (c->flags & CLIENT_READONLY) - return; + goto out; window_unzoom(w); wp = window_pane_at_index(w, key - '0'); server_client_clear_identify(c, wp); - return; + goto out; } /* Handle status line. */ @@ -1021,19 +1033,19 @@ server_client_handle_key(struct client *c, key_code key) } if (c->prompt_string != NULL) { if (c->flags & CLIENT_READONLY) - return; + goto out; if (status_prompt_key(c, key) == 0) - return; + goto out; } /* Check for mouse keys. */ m->valid = 0; if (key == KEYC_MOUSE) { if (c->flags & CLIENT_READONLY) - return; - key = server_client_check_mouse(c); + goto out; + key = server_client_check_mouse(c, event); if (key == KEYC_UNKNOWN) - return; + goto out; m->valid = 1; m->key = key; @@ -1044,10 +1056,9 @@ server_client_handle_key(struct client *c, key_code key) */ if (key == KEYC_DRAGGING) { c->tty.mouse_drag_update(c, m); - return; + goto out; } - } else - m->valid = 0; + } /* Find affected pane. */ if (!KEYC_IS_MOUSE(key) || cmd_find_from_mouse(&fs, m, 0) != 0) @@ -1086,7 +1097,7 @@ table_changed: strcmp(table->name, "prefix") != 0) { server_client_set_key_table(c, "prefix"); server_status_client(c); - return; + goto out; } flags = c->flags; @@ -1144,9 +1155,9 @@ try_again: server_status_client(c); /* Execute the key binding. */ - key_bindings_dispatch(bd, NULL, c, m, &fs); + key_bindings_dispatch(bd, item, c, m, &fs); key_bindings_unref_table(table); - return; + goto out; } /* @@ -1181,14 +1192,18 @@ try_again: if (first != table && (~flags & CLIENT_REPEAT)) { server_client_set_key_table(c, NULL); server_status_client(c); - return; + goto out; } forward_key: if (c->flags & CLIENT_READONLY) - return; + goto out; if (wp != NULL) window_pane_key(wp, c, s, wl, key, m); + +out: + free(event); + return (CMD_RETURN_NORMAL); } /* Client functions that need to happen every loop. */ |