abduco

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | LICENSE

commit 6000bc6240a62f057ac2899cab2090e615d9db85
parent a99e46fd23cdf6ae9df301ffb885e498a9c38036
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Fri, 21 Mar 2014 21:57:50 +0100

Request screen size if most recently connected client disconnects

Diffstat:
abduco.c | 1-
client.c | 3+++
server.c | 8++++++--
3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/abduco.c b/abduco.c @@ -92,7 +92,6 @@ struct Client { typedef struct { Client *clients; - int client_count; int socket; Packet pty_output; int pty; diff --git a/client.c b/client.c @@ -68,6 +68,9 @@ static int client_mainloop() { case MSG_CONTENT: write_all(STDOUT_FILENO, pkt.u.msg, pkt.len); break; + case MSG_RESIZE: + client.need_resize = true; + break; case MSG_EXIT: return pkt.u.i; } diff --git a/server.c b/server.c @@ -70,7 +70,6 @@ static Client *server_accept_client() { c->state = STATE_CONNECTED; c->next = server.clients; server.clients = c; - server.client_count++; return c; } @@ -188,11 +187,16 @@ static void server_mainloop() { for (Client **prev_next = &server.clients, *c = server.clients; c;) { if (c->state == STATE_DISCONNECTED) { + bool first = (c == server.clients); Client *t = c->next; client_free(c); *prev_next = c = t; - if (--server.client_count == 0) + if (first && server.clients) { + Packet pkt = { .type = MSG_RESIZE, .len = 0 }; + server_send_packet(server.clients, &pkt); + } else if (!server.clients) { server_mark_socket_exec(false); + } continue; }