From a0ee21c7dcca37864552f9fe6e685e70255d5977 Mon Sep 17 00:00:00 2001 From: Callum Lowcay Date: Fri, 7 Jan 2011 19:46:56 +0000 Subject: [PATCH] terminal: Window size ioctls Use TIOCSWINSZ ioctl to set window size on terminal resize. This causes applications to be notified of the resize event. Signed-off-by: Callum Lowcay --- clients/terminal.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/clients/terminal.c b/clients/terminal.c index 6864967..3c7be25 100644 --- a/clients/terminal.c +++ b/clients/terminal.c @@ -268,6 +268,8 @@ terminal_resize(struct terminal *terminal, int width, int height) struct attr *data_attr; int data_pitch, attr_pitch; int i, l, total_rows, start; + struct rectangle rectangle; + struct winsize ws; if (terminal->width == width && terminal->height == height) return; @@ -318,6 +320,22 @@ terminal_resize(struct terminal *terminal, int width, int height) if (terminal->column >= terminal->width) terminal->column = terminal->width - 1; terminal->start = 0; + + if (!terminal->fullscreen) { + rectangle.width = terminal->width * + terminal->extents.max_x_advance + 2 * terminal->margin; + rectangle.height = terminal->height * + terminal->extents.height + 2 * terminal->margin; + window_set_child_size(terminal->window, &rectangle); + } + + /* Update the window size */ + ws.ws_row = terminal->height; + ws.ws_col = terminal->width; + window_get_child_rectangle(terminal->window, &rectangle); + ws.ws_xpixel = rectangle.width; + ws.ws_ypixel = rectangle.height; + ioctl(terminal->master, TIOCSWINSZ, &ws); } struct color_scheme DEFAULT_COLORS = { @@ -480,14 +498,6 @@ terminal_draw(struct terminal *terminal) (int32_t) terminal->extents.height; terminal_resize(terminal, width, height); - if (!terminal->fullscreen) { - rectangle.width = terminal->width * - terminal->extents.max_x_advance + 2 * terminal->margin; - rectangle.height = terminal->height * - terminal->extents.height + 2 * terminal->margin; - window_set_child_size(terminal->window, &rectangle); - } - window_draw(terminal->window); terminal_draw_contents(terminal); window_flush(terminal->window); @@ -893,6 +903,7 @@ terminal_create(struct display *display, int fullscreen) cairo_destroy(cr); cairo_surface_destroy(surface); + terminal_resize(terminal, 80, 24); terminal_draw(terminal); return terminal; -- 2.7.4