aboutsummaryrefslogtreecommitdiff
path: root/server-client.c
diff options
context:
space:
mode:
authornicm <nicm>2019-05-07 11:24:03 +0000
committernicm <nicm>2019-05-07 11:24:03 +0000
commit85a9c2f52b8855560fa9fdaa033d1c7bca738429 (patch)
treeb1e0274124ba02ba6cb5c368bbcd09394e782405 /server-client.c
parent69440d19b783c72139f22c5c72b34b55d99e71de (diff)
downloadrtmux-85a9c2f52b8855560fa9fdaa033d1c7bca738429.tar.gz
rtmux-85a9c2f52b8855560fa9fdaa033d1c7bca738429.tar.bz2
rtmux-85a9c2f52b8855560fa9fdaa033d1c7bca738429.zip
Treat keys in identify mode (display-panes) specially and handle them
immediately rather than queuing them (the command can block the queue which means they were not being seen until it finished which was too late). Reported by denis@ and solene@, ok solene@.
Diffstat (limited to 'server-client.c')
-rw-r--r--server-client.c40
1 files changed, 39 insertions, 1 deletions
diff --git a/server-client.c b/server-client.c
index 13a589ef..2840ba60 100644
--- a/server-client.c
+++ b/server-client.c
@@ -986,7 +986,7 @@ server_client_assume_paste(struct session *s)
* 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
+static enum cmd_retval
server_client_key_callback(struct cmdq_item *item, void *data)
{
struct client *c = item->client;
@@ -1206,6 +1206,44 @@ out:
return (CMD_RETURN_NORMAL);
}
+/* Handle a key event. */
+int
+server_client_handle_key(struct client *c, struct key_event *event)
+{
+ struct session *s = c->session;
+ struct window *w;
+ struct window_pane *wp = NULL;
+ struct cmdq_item *item;
+
+ /* Check the client is good to accept input. */
+ if (s == NULL || (c->flags & (CLIENT_DEAD|CLIENT_SUSPENDED)) != 0)
+ return (0);
+ w = s->curw->window;
+
+ /*
+ * Key presses in identify mode are a special case. The queue might be
+ * blocked so they need to be processed immediately rather than queued.
+ */
+ if (c->flags & CLIENT_IDENTIFY) {
+ if (c->flags & CLIENT_READONLY)
+ return (0);
+ if (event->key >= '0' && event->key <= '9') {
+ window_unzoom(w);
+ wp = window_pane_at_index(w, event->key - '0');
+ }
+ server_client_clear_identify(c, wp);
+ return (0);
+ }
+
+ /*
+ * Add the key to the queue so it happens after any commands queued by
+ * previous keys.
+ */
+ item = cmdq_get_callback(server_client_key_callback, event);
+ cmdq_append(c, item);
+ return (1);
+}
+
/* Client functions that need to happen every loop. */
void
server_client_loop(void)