diff options
author | Thomas Adam <thomas@xteddy.org> | 2019-11-28 12:18:41 +0000 |
---|---|---|
committer | Thomas Adam <thomas@xteddy.org> | 2019-11-28 12:18:41 +0000 |
commit | 5f5f029e3b3a782dc616778739b2801b00b17c0e (patch) | |
tree | fad35dccc37c54e45d0ecc497d3b915dd7b835aa | |
parent | c13838436e6883d191374f1628e675bfbb8c8aeb (diff) | |
parent | fa409194d3dfe0095bf6572a253772f2825f5dec (diff) | |
download | rtmux-5f5f029e3b3a782dc616778739b2801b00b17c0e.tar.gz rtmux-5f5f029e3b3a782dc616778739b2801b00b17c0e.tar.bz2 rtmux-5f5f029e3b3a782dc616778739b2801b00b17c0e.zip |
Merge branch 'obsd-master'
-rw-r--r-- | cmd-break-pane.c | 2 | ||||
-rw-r--r-- | cmd-refresh-client.c | 2 | ||||
-rw-r--r-- | cmd-resize-window.c | 14 | ||||
-rw-r--r-- | format.c | 4 | ||||
-rw-r--r-- | input.c | 2 | ||||
-rw-r--r-- | layout-custom.c | 2 | ||||
-rw-r--r-- | layout-set.c | 8 | ||||
-rw-r--r-- | options-table.c | 11 | ||||
-rw-r--r-- | resize.c | 51 | ||||
-rw-r--r-- | screen-write.c | 3 | ||||
-rw-r--r-- | server-client.c | 6 | ||||
-rw-r--r-- | spawn.c | 9 | ||||
-rw-r--r-- | tmux.1 | 6 | ||||
-rw-r--r-- | tmux.h | 23 | ||||
-rw-r--r-- | tty-keys.c | 26 | ||||
-rw-r--r-- | tty-term.c | 3 | ||||
-rw-r--r-- | tty.c | 26 | ||||
-rw-r--r-- | window.c | 42 | ||||
-rw-r--r-- | xmalloc.c | 14 | ||||
-rw-r--r-- | xmalloc.h | 1 |
20 files changed, 196 insertions, 59 deletions
diff --git a/cmd-break-pane.c b/cmd-break-pane.c index 8b430ff7..6c638103 100644 --- a/cmd-break-pane.c +++ b/cmd-break-pane.c @@ -76,7 +76,7 @@ cmd_break_pane_exec(struct cmd *self, struct cmdq_item *item) window_lost_pane(w, wp); layout_close_pane(wp); - w = wp->window = window_create(w->sx, w->sy); + w = wp->window = window_create(w->sx, w->sy, w->xpixel, w->ypixel); options_set_parent(wp->options, w->options); wp->flags |= PANE_STYLECHANGED; TAILQ_INSERT_HEAD(&w->panes, wp, entry); diff --git a/cmd-refresh-client.c b/cmd-refresh-client.c index 49921a74..b4c5e844 100644 --- a/cmd-refresh-client.c +++ b/cmd-refresh-client.c @@ -130,7 +130,7 @@ cmd_refresh_client_exec(struct cmd *self, struct cmdq_item *item) cmdq_error(item, "size too small or too big"); return (CMD_RETURN_ERROR); } - tty_set_size(&c->tty, x, y); + tty_set_size(&c->tty, x, y, 0, 0); c->flags |= CLIENT_SIZECHANGED; recalculate_sizes(); } diff --git a/cmd-resize-window.c b/cmd-resize-window.c index c5a7c5a1..9cc74e82 100644 --- a/cmd-resize-window.c +++ b/cmd-resize-window.c @@ -53,6 +53,7 @@ cmd_resize_window_exec(struct cmd *self, struct cmdq_item *item) const char *errstr; char *cause; u_int adjust, sx, sy; + int xpixel = -1, ypixel = -1; if (args->argc == 0) adjust = 1; @@ -97,13 +98,16 @@ cmd_resize_window_exec(struct cmd *self, struct cmdq_item *item) } else if (args_has(args, 'D')) sy += adjust; - if (args_has(args, 'A')) - default_window_size(NULL, s, w, &sx, &sy, WINDOW_SIZE_LARGEST); - else if (args_has(args, 'a')) - default_window_size(NULL, s, w, &sx, &sy, WINDOW_SIZE_SMALLEST); + if (args_has(args, 'A')) { + default_window_size(NULL, s, w, &sx, &sy, &xpixel, &ypixel, + WINDOW_SIZE_LARGEST); + } else if (args_has(args, 'a')) { + default_window_size(NULL, s, w, &sx, &sy, &xpixel, &ypixel, + WINDOW_SIZE_SMALLEST); + } options_set_number(w->options, "window-size", WINDOW_SIZE_MANUAL); - resize_window(w, sx, sy); + resize_window(w, sx, sy, xpixel, ypixel); return (CMD_RETURN_NORMAL); } @@ -2174,6 +2174,8 @@ format_defaults_client(struct format_tree *ft, struct client *c) format_add(ft, "client_pid", "%ld", (long) c->pid); format_add(ft, "client_height", "%u", tty->sy); format_add(ft, "client_width", "%u", tty->sx); + format_add(ft, "client_cell_width", "%u", tty->xpixel); + format_add(ft, "client_cell_height", "%u", tty->ypixel); format_add(ft, "client_tty", "%s", c->ttyname); format_add(ft, "client_control_mode", "%d", !!(c->flags & CLIENT_CONTROL)); @@ -2225,6 +2227,8 @@ format_defaults_window(struct format_tree *ft, struct window *w) format_add(ft, "window_name", "%s", w->name); format_add(ft, "window_width", "%u", w->sx); format_add(ft, "window_height", "%u", w->sy); + format_add(ft, "window_cell_width", "%u", w->xpixel); + format_add(ft, "window_cell_height", "%u", w->ypixel); format_add_cb(ft, "window_layout", format_cb_window_layout); format_add_cb(ft, "window_visible_layout", format_cb_window_visible_layout); @@ -740,7 +740,7 @@ input_timer_callback(__unused int fd, __unused short events, void *arg) static void input_start_timer(struct input_ctx *ictx) { - struct timeval tv = { .tv_usec = 100000 }; + struct timeval tv = { .tv_sec = 5, .tv_usec = 0 }; event_del(&ictx->timer); event_add(&ictx->timer, &tv); diff --git a/layout-custom.c b/layout-custom.c index d7371292..097dabe6 100644 --- a/layout-custom.c +++ b/layout-custom.c @@ -221,7 +221,7 @@ layout_parse(struct window *w, const char *layout) return (-1); /* Resize to the layout size. */ - window_resize(w, lc->sx, lc->sy); + window_resize(w, lc->sx, lc->sy, -1, -1); /* Destroy the old layout and swap to the new. */ layout_free_cell(w->layout_root); diff --git a/layout-set.c b/layout-set.c index 82247149..f712b059 100644 --- a/layout-set.c +++ b/layout-set.c @@ -163,7 +163,7 @@ layout_set_even(struct window *w, enum layout_type type) layout_print_cell(w->layout_root, __func__, 1); - window_resize(w, lc->sx, lc->sy); + window_resize(w, lc->sx, lc->sy, -1, -1); notify_window("window-layout-changed", w); server_redraw_window(w); } @@ -262,7 +262,7 @@ layout_set_main_h(struct window *w) layout_print_cell(w->layout_root, __func__, 1); - window_resize(w, lc->sx, lc->sy); + window_resize(w, lc->sx, lc->sy, -1, -1); notify_window("window-layout-changed", w); server_redraw_window(w); } @@ -349,7 +349,7 @@ layout_set_main_v(struct window *w) layout_print_cell(w->layout_root, __func__, 1); - window_resize(w, lc->sx, lc->sy); + window_resize(w, lc->sx, lc->sy, -1, -1); notify_window("window-layout-changed", w); server_redraw_window(w); } @@ -458,7 +458,7 @@ layout_set_tiled(struct window *w) layout_print_cell(w->layout_root, __func__, 1); - window_resize(w, lc->sx, lc->sy); + window_resize(w, lc->sx, lc->sy, -1, -1); notify_window("window-layout-changed", w); server_redraw_window(w); } diff --git a/options-table.c b/options-table.c index e0451e26..be0d220d 100644 --- a/options-table.c +++ b/options-table.c @@ -69,7 +69,10 @@ static const char *options_table_window_size_list[] = { /* Status line format. */ #define OPTIONS_TABLE_STATUS_FORMAT1 \ "#[align=left range=left #{status-left-style}]" \ - "#{T;=/#{status-left-length}:status-left}#[norange default]" \ + "#[push-default]" \ + "#{T;=/#{status-left-length}:status-left}" \ + "#[pop-default]" \ + "#[norange default]" \ "#[list=on align=#{status-justify}]" \ "#[list=left-marker]<#[list=right-marker]>#[list=on]" \ "#{W:" \ @@ -125,7 +128,10 @@ static const char *options_table_window_size_list[] = { "#{?window_end_flag,,#{window-status-separator}}" \ "}" \ "#[nolist align=right range=right #{status-right-style}]" \ - "#{T;=/#{status-right-length}:status-right}#[norange default]" + "#[push-default]" \ + "#{T;=/#{status-right-length}:status-right}" \ + "#[pop-default]" \ + "#[norange default]" #define OPTIONS_TABLE_STATUS_FORMAT2 \ "#[align=centre]#{P:#{?pane_active,#[reverse],}" \ "#{pane_index}[#{pane_width}x#{pane_height}]#[default] }" @@ -804,6 +810,7 @@ const struct options_table_entry options_table[] = { OPTIONS_TABLE_HOOK("after-copy-mode", ""), OPTIONS_TABLE_HOOK("after-display-message", ""), OPTIONS_TABLE_HOOK("after-display-panes", ""), + OPTIONS_TABLE_HOOK("after-kill-pane", ""), OPTIONS_TABLE_HOOK("after-list-buffers", ""), OPTIONS_TABLE_HOOK("after-list-clients", ""), OPTIONS_TABLE_HOOK("after-list-keys", ""), @@ -23,7 +23,7 @@ #include "tmux.h" void -resize_window(struct window *w, u_int sx, u_int sy) +resize_window(struct window *w, u_int sx, u_int sy, int xpixel, int ypixel) { int zoomed; @@ -50,7 +50,7 @@ resize_window(struct window *w, u_int sx, u_int sy) sx = w->layout_root->sx; if (sy < w->layout_root->sy) sy = w->layout_root->sy; - window_resize(w, sx, sy); + window_resize(w, sx, sy, xpixel, ypixel); log_debug("%s: @%u resized to %u,%u; layout %u,%u", __func__, w->id, sx, sy, w->layout_root->sx, w->layout_root->sy); @@ -77,7 +77,7 @@ ignore_client_size(struct client *c) void default_window_size(struct client *c, struct session *s, struct window *w, - u_int *sx, u_int *sy, int type) + u_int *sx, u_int *sy, u_int *xpixel, u_int *ypixel, int type) { struct client *loop; u_int cx, cy; @@ -88,6 +88,7 @@ default_window_size(struct client *c, struct session *s, struct window *w, switch (type) { case WINDOW_SIZE_LARGEST: *sx = *sy = 0; + *xpixel = *ypixel = 0; TAILQ_FOREACH(loop, &clients, entry) { if (ignore_client_size(loop)) continue; @@ -103,12 +104,19 @@ default_window_size(struct client *c, struct session *s, struct window *w, *sx = cx; if (cy > *sy) *sy = cy; + + if (loop->tty.xpixel > *xpixel && + loop->tty.ypixel > *ypixel) { + *xpixel = loop->tty.xpixel; + *ypixel = loop->tty.ypixel; + } } if (*sx == 0 || *sy == 0) goto manual; break; case WINDOW_SIZE_SMALLEST: *sx = *sy = UINT_MAX; + *xpixel = *ypixel = 0; TAILQ_FOREACH(loop, &clients, entry) { if (ignore_client_size(loop)) continue; @@ -124,6 +132,12 @@ default_window_size(struct client *c, struct session *s, struct window *w, *sx = cx; if (cy < *sy) *sy = cy; + + if (loop->tty.xpixel > *xpixel && + loop->tty.ypixel > *ypixel) { + *xpixel = loop->tty.xpixel; + *ypixel = loop->tty.ypixel; + } } if (*sx == UINT_MAX || *sy == UINT_MAX) goto manual; @@ -132,8 +146,11 @@ default_window_size(struct client *c, struct session *s, struct window *w, if (c != NULL && !ignore_client_size(c)) { *sx = c->tty.sx; *sy = c->tty.sy - status_line_size(c); + *xpixel = c->tty.xpixel; + *ypixel = c->tty.ypixel; } else { *sx = *sy = UINT_MAX; + *xpixel = *ypixel = 0; TAILQ_FOREACH(loop, &clients, entry) { if (ignore_client_size(loop)) continue; @@ -148,6 +165,12 @@ default_window_size(struct client *c, struct session *s, struct window *w, *sx = cx; if (cy < *sy) *sy = cy; + + if (loop->tty.xpixel > *xpixel && + loop->tty.ypixel > *ypixel) { + *xpixel = loop->tty.xpixel; + *ypixel = loop->tty.ypixel; + } } if (*sx == UINT_MAX || *sy == UINT_MAX) goto manual; @@ -181,7 +204,7 @@ recalculate_size(struct window *w) { struct session *s; struct client *c; - u_int sx, sy, cx, cy; + u_int sx, sy, cx, cy, xpixel = 0, ypixel = 0; int type, current, has, changed; if (w->active == NULL) @@ -214,6 +237,11 @@ recalculate_size(struct window *w) sx = cx; if (cy > sy) sy = cy; + + if (c->tty.xpixel > xpixel && c->tty.ypixel > ypixel) { + xpixel = c->tty.xpixel; + ypixel = c->tty.ypixel; + } } if (sx == 0 || sy == 0) changed = 0; @@ -239,6 +267,11 @@ recalculate_size(struct window *w) sx = cx; if (cy < sy) sy = cy; + + if (c->tty.xpixel > xpixel && c->tty.ypixel > ypixel) { + xpixel = c->tty.xpixel; + ypixel = c->tty.ypixel; + } } if (sx == UINT_MAX || sy == UINT_MAX) changed = 0; @@ -266,6 +299,11 @@ recalculate_size(struct window *w) sx = cx; if (cy < sy) sy = cy; + + if (c->tty.xpixel > xpixel && c->tty.ypixel > ypixel) { + xpixel = c->tty.xpixel; + ypixel = c->tty.ypixel; + } } if (sx == UINT_MAX || sy == UINT_MAX) changed = 0; @@ -281,8 +319,9 @@ recalculate_size(struct window *w) tty_update_window_offset(w); return; } - log_debug("%s: @%u changed to %u,%u", __func__, w->id, sx, sy); - resize_window(w, sx, sy); + log_debug("%s: @%u changed to %u,%u (%ux%u)", __func__, w->id, sx, sy, + xpixel, ypixel); + resize_window(w, sx, sy, xpixel, ypixel); } void diff --git a/screen-write.c b/screen-write.c index 34d16ee8..43cb42b4 100644 --- a/screen-write.c +++ b/screen-write.c @@ -1636,7 +1636,8 @@ screen_write_overwrite(struct screen_write_ctx *ctx, struct grid_cell *gc, grid_view_get_cell(gd, xx, s->cy, &tmp_gc); if (~tmp_gc.flags & GRID_FLAG_PADDING) break; - log_debug("%s: overwrite at %u,%u", __func__, xx, s->cy); + log_debug("%s: overwrite at %u,%u", __func__, xx, + s->cy); grid_view_set_cell(gd, xx, s->cy, &grid_default_cell); done = 1; } diff --git a/server-client.c b/server-client.c index cedd00a1..d8907f2a 100644 --- a/server-client.c +++ b/server-client.c @@ -541,7 +541,8 @@ have_event: where = STATUS_RIGHT; break; case STYLE_RANGE_WINDOW: - wl = winlink_find_by_index(&s->windows, sr->argument); + wl = winlink_find_by_index(&s->windows, + sr->argument); if (wl == NULL) return (KEYC_UNKNOWN); m->w = wl->window->id; @@ -1319,7 +1320,6 @@ static int server_client_resize_force(struct window_pane *wp) { struct timeval tv = { .tv_usec = 100000 }; - struct winsize ws; /* * If we are resizing to the same size as when we entered the loop @@ -1349,6 +1349,7 @@ server_client_resize_force(struct window_pane *wp) #endif fatal("ioctl failed"); log_debug("%s: %%%u forcing resize", __func__, wp->id); + window_pane_send_resize(wp, -1); evtimer_add(&wp->resize_timer, &tv); wp->flags |= PANE_RESIZEFORCE; @@ -1376,6 +1377,7 @@ server_client_resize_pane(struct window_pane *wp) #endif fatal("ioctl failed"); log_debug("%s: %%%u resize to %u,%u", __func__, wp->id, wp->sx, wp->sy); + window_pane_send_resize(wp, 0); wp->flags &= ~PANE_RESIZE; @@ -83,7 +83,7 @@ spawn_window(struct spawn_context *sc, char **cause) struct window_pane *wp; struct winlink *wl; int idx = sc->idx; - u_int sx, sy; + u_int sx, sy, xpixel, ypixel; spawn_log(__func__, sc); @@ -153,8 +153,9 @@ spawn_window(struct spawn_context *sc, char **cause) xasprintf(cause, "couldn't add window %d", idx); return (NULL); } - default_window_size(sc->c, s, NULL, &sx, &sy, -1); - if ((w = window_create(sx, sy)) == NULL) { + default_window_size(sc->c, s, NULL, &sx, &sy, &xpixel, &ypixel, + -1); + if ((w = window_create(sx, sy, xpixel, ypixel)) == NULL) { winlink_remove(&s->windows, sc->wl); xasprintf(cause, "couldn't create window %d", idx); return (NULL); @@ -336,6 +337,8 @@ spawn_pane(struct spawn_context *sc, char **cause) memset(&ws, 0, sizeof ws); ws.ws_col = screen_size_x(&new_wp->base); ws.ws_row = screen_size_y(&new_wp->base); + ws.ws_xpixel = w->xpixel * ws.ws_col; + ws.ws_ypixel = w->ypixel * ws.ws_row; /* Block signals until fork has completed. */ sigfillset(&set); @@ -4214,6 +4214,8 @@ The following variables are available, where appropriate: .It Li "buffer_sample" Ta "" Ta "Sample of start of buffer" .It Li "buffer_size" Ta "" Ta "Size of the specified buffer in bytes" .It Li "client_activity" Ta "" Ta "Time client last had activity" +.It Li "client_cell_height" Ta "" Ta "Height of each client cell in pixels" +.It Li "client_cell_width" Ta "" Ta "Width of each client cell in pixels" .It Li "client_control_mode" Ta "" Ta "1 if client is in control mode" .It Li "client_created" Ta "" Ta "Time client created" .It Li "client_discarded" Ta "" Ta "Bytes discarded when client behind" @@ -4228,7 +4230,7 @@ The following variables are available, where appropriate: .It Li "client_termname" Ta "" Ta "Terminal name of client" .It Li "client_termtype" Ta "" Ta "Terminal type of client" .It Li "client_tty" Ta "" Ta "Pseudo terminal of client" -.It Li "client_utf8" Ta "" Ta "1 if client supports utf8" +.It Li "client_utf8" Ta "" Ta "1 if client supports UTF-8" .It Li "client_width" Ta "" Ta "Width of client" .It Li "client_written" Ta "" Ta "Bytes written to client" .It Li "command" Ta "" Ta "Name of command in use, if any" @@ -4334,6 +4336,8 @@ The following variables are available, where appropriate: .It Li "window_activity_flag" Ta "" Ta "1 if window has activity" .It Li "window_bell_flag" Ta "" Ta "1 if window has bell" .It Li "window_bigger" Ta "" Ta "1 if window is larger than client" +.It Li "window_cell_height" Ta "" Ta "Height of each cell in pixels" +.It Li "window_cell_width" Ta "" Ta "Width of each cell in pixels" .It Li "window_end_flag" Ta "" Ta "1 if window has the highest index" .It Li "window_flags" Ta "#F" Ta "Window flags" .It Li "window_format" Ta "" Ta "1 if format is for a window" @@ -80,6 +80,10 @@ struct winlink; /* Maximum size of data to hold from a pane. */ #define READ_SIZE 4096 +/* Default pixel cell sizes. */ +#define DEFAULT_XPIXEL 16 +#define DEFAULT_YPIXEL 32 + /* Attribute to make GCC check printf-like arguments. */ #define printflike(a, b) __attribute__ ((format (printf, a, b))) @@ -930,6 +934,8 @@ struct window { u_int sx; u_int sy; + u_int xpixel; + u_int ypixel; int flags; #define WINDOW_BELL 0x1 @@ -1150,6 +1156,8 @@ struct tty { u_int sx; u_int sy; + u_int xpixel; + u_int ypixel; u_int cx; u_int cy; @@ -1238,8 +1246,8 @@ struct tty_ctx { const struct grid_cell *cell; int wrapped; - u_int num; - void *ptr; + u_int num; + void *ptr; /* * Cursor and region position before the screen was updated - this is @@ -1929,7 +1937,7 @@ void tty_putc(struct tty *, u_char); void tty_putn(struct tty *, const void *, size_t, u_int); int tty_init(struct tty *, struct client *, int, char *); void tty_resize(struct tty *); -void tty_set_size(struct tty *, u_int, u_int); +void tty_set_size(struct tty *, u_int, u_int, u_int, u_int); void tty_start_tty(struct tty *); void tty_stop_tty(struct tty *); void tty_set_title(struct tty *, const char *); @@ -2208,9 +2216,9 @@ void status_prompt_load_history(void); void status_prompt_save_history(void); /* resize.c */ -void resize_window(struct window *, u_int, u_int); +void resize_window(struct window *, u_int, u_int, int, int); void default_window_size(struct client *, struct session *, struct window *, - u_int *, u_int *, int); + u_int *, u_int *, u_int *, u_int *, int); void recalculate_size(struct window *); void recalculate_sizes(void); @@ -2402,7 +2410,7 @@ void winlink_stack_remove(struct winlink_stack *, struct winlink *); struct window *window_find_by_id_str(const char *); struct window *window_find_by_id(u_int); void window_update_activity(struct window *); -struct window *window_create(u_int, u_int); +struct window *window_create(u_int, u_int, u_int, u_int); void window_pane_set_event(struct window_pane *); struct window_pane *window_get_active_at(struct window *, u_int, u_int); struct window_pane *window_find_string(struct window *, const char *); @@ -2413,7 +2421,8 @@ void window_redraw_active_switch(struct window *, struct window_pane *); struct window_pane *window_add_pane(struct window *, struct window_pane *, u_int, int); -void window_resize(struct window *, u_int, u_int); +void window_resize(struct window *, u_int, u_int, int, int); +void window_pane_send_resize(struct window_pane *, int); int window_zoom(struct window_pane *); int window_unzoom(struct window *); int window_push_zoom(struct window *, int); @@ -1002,8 +1002,8 @@ tty_keys_device_attributes(struct tty *tty, const char *buf, size_t len, size_t *size) { struct client *c = tty->client; - u_int i, a, b; - char tmp[64], *endptr; + u_int i, n = 0; + char tmp[64], *endptr, p[32] = { 0 }, *cp, *next; static const char *types[] = TTY_TYPES; int type; @@ -1035,23 +1035,21 @@ tty_keys_device_attributes(struct tty *tty, const char *buf, size_t len, *size = 4 + i; /* Convert version numbers. */ - a = strtoul(tmp, &endptr, 10); - if (*endptr == ';') { - b = strtoul(endptr + 1, &endptr, 10); + cp = tmp; + while ((next = strsep(&cp, ";")) != NULL) { + p[n] = strtoul(next, &endptr, 10); if (*endptr != '\0' && *endptr != ';') - b = 0; - } else if (*endptr == '\0') - b = 0; - else - a = b = 0; + p[n] = 0; + n++; + } /* Store terminal type. */ type = TTY_UNKNOWN; - switch (a) { + switch (p[0]) { case 1: - if (b == 2) + if (p[1] == 2) type = TTY_VT100; - else if (b == 0) + else if (p[1] == 0) type = TTY_VT101; break; case 6: @@ -1070,6 +1068,8 @@ tty_keys_device_attributes(struct tty *tty, const char *buf, size_t len, type = TTY_VT520; break; } + for (i = 2; i < n; i++) + log_debug("%s: DA feature: %d", c->name, p[i]); tty_set_type(tty, type); log_debug("%s: received DA %.*s (%s)", c->name, (int)*size, buf, @@ -642,7 +642,8 @@ tty_term_string2(struct tty_term *term, enum tty_code_code code, int a, int b) } const char * -tty_term_string3(struct tty_term *term, enum tty_code_code code, int a, int b, int c) +tty_term_string3(struct tty_term *term, enum tty_code_code code, int a, int b, + int c) { return (tparm((char *) tty_term_string(term, code), a, b, c, 0, 0, 0, 0, 0, 0)); } @@ -127,29 +127,40 @@ tty_resize(struct tty *tty) { struct client *c = tty->client; struct winsize ws; - u_int sx, sy; + u_int sx, sy, xpixel, ypixel; if (ioctl(tty->fd, TIOCGWINSZ, &ws) != -1) { sx = ws.ws_col; - if (sx == 0) + if (sx == 0) { sx = 80; + xpixel = 0; + } else + xpixel = ws.ws_xpixel / sx; sy = ws.ws_row; - if (sy == 0) + if (sy == 0) { sy = 24; + ypixel = 0; + } else + ypixel = ws.ws_ypixel / sy; } else { sx = 80; sy = 24; + xpixel = 0; + ypixel = 0; } - log_debug("%s: %s now %ux%u", __func__, c->name, sx, sy); - tty_set_size(tty, sx, sy); + log_debug("%s: %s now %ux%u (%ux%u)", __func__, c->name, sx, sy, + xpixel, ypixel); + tty_set_size(tty, sx, sy, xpixel, ypixel); tty_invalidate(tty); } void -tty_set_size(struct tty *tty, u_int sx, u_int sy) +tty_set_size(struct tty *tty, u_int sx, u_int sy, u_int xpixel, u_int ypixel) { tty->sx = sx; tty->sy = sy; + tty->xpixel = xpixel; + tty->ypixel = ypixel; } static void @@ -2443,7 +2454,8 @@ tty_check_bg(struct tty *tty, struct window_pane *wp, struct grid_cell *gc) } static void -tty_check_us(__unused struct tty *tty, struct window_pane *wp, struct grid_cell *gc) +tty_check_us(__unused struct tty *tty, struct window_pane *wp, + struct grid_cell *gc) { int c; @@ -306,10 +306,15 @@ window_update_activity(struct window *w) } struct window * -window_create(u_int sx, u_int sy) +window_create(u_int sx, u_int sy, u_int xpixel, u_int ypixel) { struct window *w; + if (xpixel == 0) + xpixel = DEFAULT_XPIXEL; + if (ypixel == 0) + ypixel = DEFAULT_YPIXEL; + w = xcalloc(1, sizeof *w); w->name = xstrdup(""); w->flags = 0; @@ -322,6 +327,8 @@ window_create(u_int sx, u_int sy) w->sx = sx; w->sy = sy; + w->xpixel = xpixel; + w->ypixel = ypixel; w->options = options_create(global_w_options); @@ -408,11 +415,40 @@ window_set_name(struct window *w, const char *new_name) } void -window_resize(struct window *w, u_int sx, u_int sy) +window_resize(struct window *w, u_int sx, u_int sy, int xpixel, int ypixel) { - log_debug("%s: @%u resize %ux%u", __func__, w->id, sx, sy); + if (xpixel == 0) + xpixel = DEFAULT_XPIXEL; + if (ypixel == 0) + ypixel = DEFAULT_YPIXEL; + + log_debug("%s: @%u resize %ux%u (%ux%u)", __func__, w->id, sx, sy, + xpixel == -1 ? w->xpixel : xpixel, + ypixel == -1 ? w->ypixel : ypixel); w->sx = sx; w->sy = sy; + if (xpixel != -1) + w->xpixel = xpixel; + if (ypixel != -1) + w->ypixel = ypixel; +} + +void +window_pane_send_resize(struct window_pane *wp, int yadjust) +{ + struct window *w = wp->window; + struct winsize ws; + + if (wp->fd == -1) + return; + + memset(&ws, 0, sizeof ws); + ws.ws_col = wp->sx; + ws.ws_row = wp->sy + yadjust; + ws.ws_xpixel = w->xpixel * ws.ws_col; + ws.ws_ypixel = w->ypixel * ws.ws_row; + if (ioctl(wp->fd, TIOCSWINSZ, &ws) == -1) + fatal("ioctl failed"); } int @@ -71,6 +71,20 @@ xreallocarray(void *ptr, size_t nmemb, size_t size) return new_ptr; } +void * +xrecallocarray(void *ptr, size_t oldnmemb, size_t nmemb, size_t size) +{ + void *new_ptr; + + if (nmemb == 0 || size == 0) + fatalx("xrecallocarray: zero size"); + new_ptr = recallocarray(ptr, oldnmemb, nmemb, size); + if (new_ptr == NULL) + fatalx("xrecallocarray: allocating %zu * %zu bytes: %s", + nmemb, size, strerror(errno)); + return new_ptr; +} + char * xstrdup(const char *str) { @@ -27,6 +27,7 @@ void *xmalloc(size_t); void *xcalloc(size_t, size_t); void *xrealloc(void *, size_t); void *xreallocarray(void *, size_t, size_t); +void *xrecallocarray(void *, size_t, size_t, size_t); char *xstrdup(const char *); char *xstrndup(const char *, size_t); int xasprintf(char **, const char *, ...) |