Request screen size if most recently connected client disconnects

This commit is contained in:
Marc André Tanner 2014-03-21 21:57:50 +01:00
parent a99e46fd23
commit 6000bc6240
3 changed files with 9 additions and 3 deletions

View File

@ -92,7 +92,6 @@ struct Client {
typedef struct {
Client *clients;
int client_count;
int socket;
Packet pty_output;
int pty;

View File

@ -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;
}

View File

@ -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;
}