From c5504af4a685707389888db475fb7451ff5d8d86 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Thu, 21 Mar 2013 18:47:01 +0000 Subject: [PATCH] Add various checks to turn off bits that can't work in control mode (such as lock). --- server-client.c | 13 ++++++++++--- server-fn.c | 3 +++ server-window.c | 4 ++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/server-client.c b/server-client.c index 1cae4733..b88b134e 100644 --- a/server-client.c +++ b/server-client.c @@ -356,6 +356,7 @@ server_client_handle_key(struct client *c, int key) /* Check the client is good to accept input. */ if ((c->flags & (CLIENT_DEAD|CLIENT_SUSPENDED)) != 0) return; + if (c->session == NULL) return; s = c->session; @@ -529,6 +530,9 @@ server_client_reset_state(struct client *c) if (c->flags & CLIENT_SUSPENDED) return; + if (c->flags & CLIENT_CONTROL) + return; + tty_region(&c->tty, 0, c->tty.sy - 1); status = options_get_number(oo, "status"); @@ -626,7 +630,7 @@ server_client_check_redraw(struct client *c) struct window_pane *wp; int flags, redraw; - if (c->flags & CLIENT_SUSPENDED) + if (c->flags & (CLIENT_CONTROL|CLIENT_SUSPENDED)) return; flags = c->tty.flags & TTY_FREEZE; @@ -756,6 +760,8 @@ server_client_msg_dispatch(struct client *c) if (datalen != 0) fatalx("bad MSG_RESIZE size"); + if (c->flags & CLIENT_CONTROL) + break; if (tty_resize(&c->tty)) { recalculate_sizes(); server_redraw_client(c); @@ -925,7 +931,7 @@ server_client_msg_identify( if (data->flags & IDENTIFY_CONTROL) { c->stdin_callback = control_callback; - c->flags |= (CLIENT_CONTROL|CLIENT_SUSPENDED); + c->flags |= CLIENT_CONTROL; server_write_client(c, MSG_STDIN, NULL, 0); c->tty.fd = -1; @@ -950,7 +956,8 @@ server_client_msg_identify( tty_resize(&c->tty); - c->flags |= CLIENT_TERMINAL; + if (!(data->flags & IDENTIFY_CONTROL)) + c->flags |= CLIENT_TERMINAL; } /* Handle shell message. */ diff --git a/server-fn.c b/server-fn.c index c22095dc..69857263 100644 --- a/server-fn.c +++ b/server-fn.c @@ -239,6 +239,9 @@ server_lock_client(struct client *c) size_t cmdlen; struct msg_lock_data lockdata; + if (!(c->flags & CLIENT_CONTROL)) + return; + if (c->flags & CLIENT_SUSPENDED) return; diff --git a/server-window.c b/server-window.c index 8b34fc6c..e82f0e36 100644 --- a/server-window.c +++ b/server-window.c @@ -85,7 +85,7 @@ server_window_check_bell(struct session *s, struct winlink *wl) return (0); for (i = 0; i < ARRAY_LENGTH(&clients); i++) { c = ARRAY_ITEM(&clients, i); - if (c == NULL || c->session != s) + if (c == NULL || c->session != s || (c->flags & CLIENT_CONTROL)) continue; if (!visual) { tty_bell(&c->tty); @@ -242,7 +242,7 @@ ring_bell(struct session *s) for (i = 0; i < ARRAY_LENGTH(&clients); i++) { c = ARRAY_ITEM(&clients, i); - if (c != NULL && c->session == s) + if (c != NULL && c->session == s && !(c->flags & CLIENT_CONTROL)) tty_bell(&c->tty); } }