From e37f34facc05c3ba146d4158cc7af23f6886fecd Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 7 Jun 2019 20:09:17 +0000 Subject: Do not load the config file if the server is exiting because it failed to start, otherwise commands like lsk which start the server again can end up looping infinitely. Also make the first client exit correctly. Problem reported by Wael M Nasreddine. --- server-client.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'server-client.c') diff --git a/server-client.c b/server-client.c index 52842e38..fa21fa79 100644 --- a/server-client.c +++ b/server-client.c @@ -1511,7 +1511,9 @@ server_client_click_timer(__unused int fd, __unused short events, void *data) static void server_client_check_exit(struct client *c) { - if (!(c->flags & CLIENT_EXIT)) + if (~c->flags & CLIENT_EXIT) + return; + if (c->flags & CLIENT_EXITED) return; if (EVBUFFER_LENGTH(c->stdin_data) != 0) @@ -1524,7 +1526,7 @@ server_client_check_exit(struct client *c) if (c->flags & CLIENT_ATTACHED) notify_client("client-detached", c); proc_send(c->peer, MSG_EXIT, -1, &c->retval, sizeof c->retval); - c->flags &= ~CLIENT_EXIT; + c->flags |= CLIENT_EXITED; } /* Redraw timer callback. */ -- cgit From 1a9f9c09b4bcc9f99f10190ab91f1aea5206809b Mon Sep 17 00:00:00 2001 From: nicm Date: Tue, 11 Jun 2019 13:09:00 +0000 Subject: Do not resize panes unless they are in an attached, active window. From Morten M Neergaard in GitHub issue 1782. --- server-client.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'server-client.c') diff --git a/server-client.c b/server-client.c index fa21fa79..dc57e523 100644 --- a/server-client.c +++ b/server-client.c @@ -1241,6 +1241,8 @@ server_client_loop(void) struct client *c; struct window *w; struct window_pane *wp; + struct winlink *wl; + struct session *s; int focus; TAILQ_FOREACH(c, &clients, entry) { @@ -1257,8 +1259,13 @@ server_client_loop(void) */ focus = options_get_number(global_options, "focus-events"); RB_FOREACH(w, windows, &windows) { + TAILQ_FOREACH(wl, &w->winlinks, wentry) { + s = wl->session; + if (s->attached != 0 && s->curw == wl) + break; + } TAILQ_FOREACH(wp, &w->panes, entry) { - if (wp->fd != -1) { + if (wl != NULL && wp->fd != -1) { if (focus) server_client_check_focus(wp); server_client_check_resize(wp); -- cgit From ae541287d303fb253b3cd75341c318dcc6a8db4a Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 20 Jun 2019 06:51:36 +0000 Subject: Expand command formats in %if and move the config file loading later (to when the first client has identified) so all the client formats are available, fixes problems reported by Thomas Sattler. --- server-client.c | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) (limited to 'server-client.c') diff --git a/server-client.c b/server-client.c index dc57e523..14c20617 100644 --- a/server-client.c +++ b/server-client.c @@ -1934,26 +1934,29 @@ server_client_dispatch_identify(struct client *c, struct imsg *imsg) close(c->fd); c->fd = -1; - - return; - } - - if (c->fd == -1) - return; - if (tty_init(&c->tty, c, c->fd, c->term) != 0) { - close(c->fd); - c->fd = -1; - return; + } else if (c->fd != -1) { + if (tty_init(&c->tty, c, c->fd, c->term) != 0) { + close(c->fd); + c->fd = -1; + } else { + if (c->flags & CLIENT_UTF8) + c->tty.flags |= TTY_UTF8; + if (c->flags & CLIENT_256COLOURS) + c->tty.term_flags |= TERM_256COLOURS; + tty_resize(&c->tty); + c->flags |= CLIENT_TERMINAL; + } } - if (c->flags & CLIENT_UTF8) - c->tty.flags |= TTY_UTF8; - if (c->flags & CLIENT_256COLOURS) - c->tty.term_flags |= TERM_256COLOURS; - tty_resize(&c->tty); - - if (!(c->flags & CLIENT_CONTROL)) - c->flags |= CLIENT_TERMINAL; + /* + * If this is the first client that has finished identifying, load + * configuration files. + */ + if ((~c->flags & CLIENT_EXIT) && + !cfg_finished && + c == TAILQ_FIRST(&clients) && + TAILQ_NEXT(c, entry) == NULL) + start_cfg(); } /* Handle shell message. */ -- cgit From 97a317a656e27523ed7437d8512be36080c739ed Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 20 Jun 2019 19:29:38 +0000 Subject: Need to always check focus even if not current window. --- server-client.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'server-client.c') diff --git a/server-client.c b/server-client.c index 14c20617..e4862d84 100644 --- a/server-client.c +++ b/server-client.c @@ -1265,10 +1265,11 @@ server_client_loop(void) break; } TAILQ_FOREACH(wp, &w->panes, entry) { - if (wl != NULL && wp->fd != -1) { + if (wp->fd != -1) { if (focus) server_client_check_focus(wp); - server_client_check_resize(wp); + if (wl != NULL) + server_client_check_resize(wp); } wp->flags &= ~PANE_REDRAW; } -- cgit From 87ea14328ce60fdfb8bd0aef15b7e3b3bdccb1ed Mon Sep 17 00:00:00 2001 From: nicm Date: Wed, 26 Jun 2019 18:28:31 +0000 Subject: Pass keys that aren't 0-9 on to normal key processing when display-panes is active (restores previous behaviour). --- server-client.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'server-client.c') diff --git a/server-client.c b/server-client.c index e4862d84..a982fe8e 100644 --- a/server-client.c +++ b/server-client.c @@ -1220,9 +1220,13 @@ server_client_handle_key(struct client *c, struct key_event *event) * blocked so they need to be processed immediately rather than queued. */ if ((~c->flags & CLIENT_READONLY) && c->overlay_key != NULL) { - if (c->overlay_key(c, event) != 0) + switch (c->overlay_key(c, event)) { + case 0: + return (0); + case 1: server_client_clear_overlay(c); - return (0); + return (0); + } } /* -- cgit From 6a489fa7f6360bcd9c0d6b87546d3eb6b0a3654a Mon Sep 17 00:00:00 2001 From: nicm Date: Tue, 2 Jul 2019 20:09:19 +0000 Subject: Command prompt key presses need to avoid the command queue, GitHub issue 1817. Also a tmux.1 fix from jmc. --- server-client.c | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) (limited to 'server-client.c') diff --git a/server-client.c b/server-client.c index a982fe8e..7aeead41 100644 --- a/server-client.c +++ b/server-client.c @@ -1026,16 +1026,6 @@ server_client_key_callback(struct cmdq_item *item, void *data) fatal("gettimeofday failed"); session_update_activity(s, &c->activity_time); - /* Handle status line. */ - if (~c->flags & CLIENT_READONLY) - status_message_clear(c); - if (c->prompt_string != NULL) { - if (c->flags & CLIENT_READONLY) - goto out; - if (status_prompt_key(c, key) == 0) - goto out; - } - /* Check for mouse keys. */ m->valid = 0; if (key == KEYC_MOUSE) { @@ -1216,16 +1206,24 @@ server_client_handle_key(struct client *c, struct key_event *event) return (0); /* - * Key presses in overlay mode are a special case. The queue might be - * blocked so they need to be processed immediately rather than queued. + * Key presses in overlay mode and the command prompt are a special + * case. The queue might be blocked so they need to be processed + * immediately rather than queued. */ - if ((~c->flags & CLIENT_READONLY) && c->overlay_key != NULL) { - switch (c->overlay_key(c, event)) { - case 0: - return (0); - case 1: - server_client_clear_overlay(c); - return (0); + if (~c->flags & CLIENT_READONLY) { + status_message_clear(c); + if (c->prompt_string != NULL) { + if (status_prompt_key(c, event->key) == 0) + return (0); + } + if (c->overlay_key != NULL) { + switch (c->overlay_key(c, event)) { + case 0: + return (0); + case 1: + server_client_clear_overlay(c); + return (0); + } } } -- cgit From ddf53d6e4e76463e6d777b2de7304572333935e9 Mon Sep 17 00:00:00 2001 From: nicm Date: Sat, 6 Jul 2019 20:56:34 +0000 Subject: Correctly adjust mouse position if the status line is at the top and more than one line. GitHub issue 1822. --- server-client.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'server-client.c') diff --git a/server-client.c b/server-client.c index 7aeead41..3fd16ec5 100644 --- a/server-client.c +++ b/server-client.c @@ -524,9 +524,10 @@ have_event: /* Is this on the status line? */ m->statusat = status_at_line(c); + m->statuslines = status_line_size(c); if (m->statusat != -1 && y >= (u_int)m->statusat && - y < m->statusat + status_line_size(c)) { + y < m->statusat + m->statuslines) { sr = status_get_range(c, x, y - m->statusat); if (sr == NULL) { where = STATUS_DEFAULT; @@ -555,8 +556,8 @@ have_event: /* Not on status line. Adjust position and check for border or pane. */ if (where == NOWHERE) { px = x; - if (m->statusat == 0 && y > 0) - py = y - 1; + if (m->statusat == 0 && y >= m->statuslines) + py = y - m->statuslines; else if (m->statusat > 0 && y >= (u_int)m->statusat) py = m->statusat - 1; else -- cgit From 9e7774bb966f6f90270df8a0d16efb2b2a5ba860 Mon Sep 17 00:00:00 2001 From: nicm Date: Wed, 17 Jul 2019 17:46:51 +0000 Subject: Clear overlay on normal key press. --- server-client.c | 1 + 1 file changed, 1 insertion(+) (limited to 'server-client.c') diff --git a/server-client.c b/server-client.c index 3fd16ec5..d5d88717 100644 --- a/server-client.c +++ b/server-client.c @@ -1226,6 +1226,7 @@ server_client_handle_key(struct client *c, struct key_event *event) return (0); } } + server_client_clear_overlay(c); } /* -- cgit