Skip to content

Commit

Permalink
Merge branch 'obsd-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasAdam committed Nov 28, 2019
2 parents c138384 + fa40919 commit 5f5f029
Show file tree
Hide file tree
Showing 20 changed files with 196 additions and 59 deletions.
2 changes: 1 addition & 1 deletion cmd-break-pane.c
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion cmd-refresh-client.c
Expand Up @@ -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();
}
Expand Down
14 changes: 9 additions & 5 deletions cmd-resize-window.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
4 changes: 4 additions & 0 deletions format.c
Expand Up @@ -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));
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion input.c
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion layout-custom.c
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions layout-set.c
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
11 changes: 9 additions & 2 deletions options-table.c
Expand Up @@ -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:" \
Expand Down Expand Up @@ -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] }"
Expand Down Expand Up @@ -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", ""),
Expand Down
51 changes: 45 additions & 6 deletions resize.c
Expand Up @@ -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;

Expand All @@ -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);

Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion screen-write.c
Expand Up @@ -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;
}
Expand Down
6 changes: 4 additions & 2 deletions server-client.c
Expand Up @@ -541,7 +541,8 @@ server_client_check_mouse(struct client *c, struct key_event *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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down
9 changes: 6 additions & 3 deletions spawn.c
Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 5f5f029

Please sign in to comment.