mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-10-31 22:25:25 -04:00
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 <callum@callumscode.com>
This commit is contained in:
parent
30eeae55e0
commit
a0ee21c7dc
1 changed files with 19 additions and 8 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue