From a1e222308119b3251f00b42e1ddff74a385d4249 Mon Sep 17 00:00:00 2001 From: David Aguilar Date: Tue, 17 Jan 2023 21:25:43 -0800 Subject: [PATCH] abduco: report pixel sizes to child processes that use ioctl(0, TIOCGWINSZ, ...) Add the ws_xpixel and ws_ypixel fields to the IPC packets so that abduco can properly respond to ioctl() requests for the screen size. This enables terminals such as "kitty" to display images inside of an abduco session. --- abduco.c | 4 ++++ client.c | 2 +- server.c | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/abduco.c b/abduco.c index b56e6f4..7b2da6f 100644 --- a/abduco.c +++ b/abduco.c @@ -79,6 +79,8 @@ typedef struct { struct { uint16_t rows; uint16_t cols; + uint16_t xpixels; + uint16_t ypixels; } ws; uint32_t i; uint64_t l; @@ -677,6 +679,8 @@ int main(int argc, char *argv[]) { if (ioctl(STDIN_FILENO, TIOCGWINSZ, &server.winsize) == -1) { server.winsize.ws_col = 80; server.winsize.ws_row = 25; + server.winsize.ws_xpixel = 640; + server.winsize.ws_ypixel = 480; } server.read_pty = (action == 'n'); diff --git a/client.c b/client.c index 3d6d82b..2df98f4 100644 --- a/client.c +++ b/client.c @@ -81,7 +81,7 @@ static int client_mainloop(void) { if (ioctl(STDIN_FILENO, TIOCGWINSZ, &ws) != -1) { Packet pkt = { .type = MSG_RESIZE, - .u = { .ws = { .rows = ws.ws_row, .cols = ws.ws_col } }, + .u = { .ws = { .rows = ws.ws_row, .cols = ws.ws_col, .xpixels = ws.ws_xpixel, .ypixels = ws.ws_ypixel } }, .len = sizeof(pkt.u.ws), }; if (client_send_packet(&pkt)) diff --git a/server.c b/server.c index e57773a..d3b9543 100644 --- a/server.c +++ b/server.c @@ -234,6 +234,8 @@ static void server_mainloop(void) { struct winsize ws = { 0 }; ws.ws_row = client_packet.u.ws.rows; ws.ws_col = client_packet.u.ws.cols; + ws.ws_xpixel = client_packet.u.ws.xpixels; + ws.ws_ypixel = client_packet.u.ws.ypixels; ioctl(server.pty, TIOCSWINSZ, &ws); } kill(-server.pid, SIGWINCH);