From fd451aa7962f399250fd166f207451fcf4b9cb94 Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 3 Dec 2020 07:12:11 +0000 Subject: Redraw any visible modes when status line changes so that formats like the pane title are updated. GitHub issue 2487. Also a man page fix from jmc. --- server-client.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'server-client.c') diff --git a/server-client.c b/server-client.c index 3e256a92..f85304a6 100644 --- a/server-client.c +++ b/server-client.c @@ -42,6 +42,7 @@ 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 *); static void server_client_check_redraw(struct client *); +static void server_client_check_modes(struct client *); static void server_client_set_title(struct client *); static void server_client_reset_state(struct client *); static int server_client_assume_paste(struct session *); @@ -1355,6 +1356,7 @@ server_client_loop(void) TAILQ_FOREACH(c, &clients, entry) { server_client_check_exit(c); if (c->session != NULL) { + server_client_check_modes(c); server_client_check_redraw(c); server_client_reset_state(c); } @@ -1810,6 +1812,28 @@ server_client_redraw_timer(__unused int fd, __unused short events, log_debug("redraw timer fired"); } +/* + * Check if modes need to be updated. Only modes in the current window are + * updated and it is done when the status line is redrawn. + */ +static void +server_client_check_modes(struct client *c) +{ + struct window *w = c->session->curw->window; + struct window_pane *wp; + struct window_mode_entry *wme; + + if (c->flags & (CLIENT_CONTROL|CLIENT_SUSPENDED)) + return; + if (~c->flags & CLIENT_REDRAWSTATUS) + return; + TAILQ_FOREACH(wp, &w->panes, entry) { + wme = TAILQ_FIRST(&wp->modes); + if (wme != NULL && wme->mode->update != NULL) + wme->mode->update(wme); + } +} + /* Check for client redraws. */ static void server_client_check_redraw(struct client *c) -- cgit From a3011be0d267a090c8bfa01a4ebe093bc203a1c4 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Sun, 17 Jan 2021 17:21:51 +0000 Subject: Look for libevent2 differently from libevent for platforms with both. --- server-client.c | 1 - 1 file changed, 1 deletion(-) (limited to 'server-client.c') diff --git a/server-client.c b/server-client.c index 451fe2eb..75a5719c 100644 --- a/server-client.c +++ b/server-client.c @@ -21,7 +21,6 @@ #include #include -#include #include #include #include -- cgit From 0730dce5abf5e43f8e3820a1d4e8754e61874a3d Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 18 Jan 2021 11:14:23 +0000 Subject: Hide some warnings on newer GCC versions, GitHUb issue 2525. --- server-client.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'server-client.c') diff --git a/server-client.c b/server-client.c index f85304a6..a55188d1 100644 --- a/server-client.c +++ b/server-client.c @@ -1781,11 +1781,11 @@ server_client_check_exit(struct client *c) switch (c->exit_type) { case CLIENT_EXIT_RETURN: - if (c->exit_message != NULL) { + if (c->exit_message != NULL) msize = strlen(c->exit_message) + 1; - size = (sizeof c->retval) + msize; - } else - size = (sizeof c->retval); + else + msize = 0; + size = (sizeof c->retval) + msize; data = xmalloc(size); memcpy(data, &c->retval, sizeof c->retval); if (c->exit_message != NULL) -- cgit From c579be1f2a8205c6405f7c6fdb229b31f30274c8 Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 8 Feb 2021 08:33:54 +0000 Subject: Include "focused" in client flags, from Dan Aloni in GitHub issue 2558. --- server-client.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'server-client.c') diff --git a/server-client.c b/server-client.c index a55188d1..52df8110 100644 --- a/server-client.c +++ b/server-client.c @@ -2454,6 +2454,8 @@ server_client_get_flags(struct client *c) *s = '\0'; if (c->flags & CLIENT_ATTACHED) strlcat(s, "attached,", sizeof s); + if (c->flags & CLIENT_FOCUSED) + strlcat(s, "focused,", sizeof s); if (c->flags & CLIENT_CONTROL) strlcat(s, "control-mode,", sizeof s); if (c->flags & CLIENT_IGNORESIZE) -- cgit From e40831a0023705885643284b574913e08a59f496 Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 11 Feb 2021 08:28:45 +0000 Subject: Move file handling protocol stuff all into file.c so it can be reused more easily. --- server-client.c | 77 +++------------------------------------------------------ 1 file changed, 3 insertions(+), 74 deletions(-) (limited to 'server-client.c') diff --git a/server-client.c b/server-client.c index 52df8110..7d9cc0e6 100644 --- a/server-client.c +++ b/server-client.c @@ -51,12 +51,6 @@ static void server_client_dispatch(struct imsg *, void *); static void server_client_dispatch_command(struct client *, struct imsg *); static void server_client_dispatch_identify(struct client *, struct imsg *); static void server_client_dispatch_shell(struct client *); -static void server_client_dispatch_write_ready(struct client *, - struct imsg *); -static void server_client_dispatch_read_data(struct client *, - struct imsg *); -static void server_client_dispatch_read_done(struct client *, - struct imsg *); /* Compare client windows. */ static int @@ -2070,13 +2064,13 @@ server_client_dispatch(struct imsg *imsg, void *arg) server_client_dispatch_shell(c); break; case MSG_WRITE_READY: - server_client_dispatch_write_ready(c, imsg); + file_write_ready(&c->files, imsg); break; case MSG_READ: - server_client_dispatch_read_data(c, imsg); + file_read_data(&c->files, imsg); break; case MSG_READ_DONE: - server_client_dispatch_read_done(c, imsg); + file_read_done(&c->files, imsg); break; } } @@ -2302,71 +2296,6 @@ server_client_dispatch_shell(struct client *c) proc_kill_peer(c->peer); } -/* Handle write ready message. */ -static void -server_client_dispatch_write_ready(struct client *c, struct imsg *imsg) -{ - struct msg_write_ready *msg = imsg->data; - size_t msglen = imsg->hdr.len - IMSG_HEADER_SIZE; - struct client_file find, *cf; - - if (msglen != sizeof *msg) - fatalx("bad MSG_WRITE_READY size"); - find.stream = msg->stream; - if ((cf = RB_FIND(client_files, &c->files, &find)) == NULL) - return; - if (msg->error != 0) { - cf->error = msg->error; - file_fire_done(cf); - } else - file_push(cf); -} - -/* Handle read data message. */ -static void -server_client_dispatch_read_data(struct client *c, struct imsg *imsg) -{ - struct msg_read_data *msg = imsg->data; - size_t msglen = imsg->hdr.len - IMSG_HEADER_SIZE; - struct client_file find, *cf; - void *bdata = msg + 1; - size_t bsize = msglen - sizeof *msg; - - if (msglen < sizeof *msg) - fatalx("bad MSG_READ_DATA size"); - find.stream = msg->stream; - if ((cf = RB_FIND(client_files, &c->files, &find)) == NULL) - return; - - log_debug("%s: file %d read %zu bytes", c->name, cf->stream, bsize); - if (cf->error == 0) { - if (evbuffer_add(cf->buffer, bdata, bsize) != 0) { - cf->error = ENOMEM; - file_fire_done(cf); - } else - file_fire_read(cf); - } -} - -/* Handle read done message. */ -static void -server_client_dispatch_read_done(struct client *c, struct imsg *imsg) -{ - struct msg_read_done *msg = imsg->data; - size_t msglen = imsg->hdr.len - IMSG_HEADER_SIZE; - struct client_file find, *cf; - - if (msglen != sizeof *msg) - fatalx("bad MSG_READ_DONE size"); - find.stream = msg->stream; - if ((cf = RB_FIND(client_files, &c->files, &find)) == NULL) - return; - - log_debug("%s: file %d read done", c->name, cf->stream); - cf->error = msg->error; - file_fire_done(cf); -} - /* Get client working directory. */ const char * server_client_get_cwd(struct client *c, struct session *s) -- cgit From af3ffa9c41936078d27b5ba1f96cec67850f98cb Mon Sep 17 00:00:00 2001 From: nicm Date: Wed, 17 Feb 2021 07:18:36 +0000 Subject: Move the call to setupterm() into the client and have it pass the results to the server over imsg, means the server does not need to enter ncurses or read terminfo db. Old clients will not work with a new server. --- server-client.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'server-client.c') diff --git a/server-client.c b/server-client.c index 7d9cc0e6..adeea5dd 100644 --- a/server-client.c +++ b/server-client.c @@ -307,6 +307,7 @@ server_client_lost(struct client *c) free(c->term_name); free(c->term_type); + tty_term_free_list(c->term_caps, c->term_ncaps); status_free(c); @@ -1997,16 +1998,17 @@ server_client_dispatch(struct imsg *imsg, void *arg) datalen = imsg->hdr.len - IMSG_HEADER_SIZE; switch (imsg->hdr.type) { + case MSG_IDENTIFY_CLIENTPID: + case MSG_IDENTIFY_CWD: + case MSG_IDENTIFY_ENVIRON: case MSG_IDENTIFY_FEATURES: case MSG_IDENTIFY_FLAGS: case MSG_IDENTIFY_LONGFLAGS: - case MSG_IDENTIFY_TERM: - case MSG_IDENTIFY_TTYNAME: - case MSG_IDENTIFY_CWD: case MSG_IDENTIFY_STDIN: case MSG_IDENTIFY_STDOUT: - case MSG_IDENTIFY_ENVIRON: - case MSG_IDENTIFY_CLIENTPID: + case MSG_IDENTIFY_TERM: + case MSG_IDENTIFY_TERMINFO: + case MSG_IDENTIFY_TTYNAME: case MSG_IDENTIFY_DONE: server_client_dispatch_identify(c, imsg); break; @@ -2200,6 +2202,14 @@ server_client_dispatch_identify(struct client *c, struct imsg *imsg) c->term_name = xstrdup(data); log_debug("client %p IDENTIFY_TERM %s", c, data); break; + case MSG_IDENTIFY_TERMINFO: + if (datalen == 0 || data[datalen - 1] != '\0') + fatalx("bad MSG_IDENTIFY_TERMINFO string"); + c->term_caps = xreallocarray(c->term_caps, c->term_ncaps + 1, + sizeof *c->term_caps); + c->term_caps[c->term_ncaps++] = xstrdup(data); + log_debug("client %p IDENTIFY_TERMINFO %s", c, data); + break; case MSG_IDENTIFY_TTYNAME: if (datalen == 0 || data[datalen - 1] != '\0') fatalx("bad MSG_IDENTIFY_TTYNAME string"); -- cgit