Skip to content

Commit

Permalink
Always need the visible window when calculating offset so no need for
Browse files Browse the repository at this point in the history
an argument.
  • Loading branch information
nicm committed Aug 19, 2018
1 parent 0d35ae7 commit fff1d60
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 15 deletions.
3 changes: 2 additions & 1 deletion cmd-select-pane.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ cmd_select_pane_redraw(struct window *w)
TAILQ_FOREACH(c, &clients, entry) {
if (c->session == NULL)
continue;
if (tty_window_bigger(&c->tty, w, tty_status_lines(c)))
if (c->session->curw->window == w &&
tty_window_bigger(&c->tty, tty_status_lines(c)))
server_redraw_client(c);
else {
if (c->session->curw->window == w)
Expand Down
2 changes: 1 addition & 1 deletion screen-redraw.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ screen_redraw_set_context(struct client *c, struct screen_redraw_ctx *ctx)
ctx->top = 1;
ctx->pane_status = options_get_number(wo, "pane-border-status");

tty_window_offset(&c->tty, w, ctx->lines, &ctx->ox, &ctx->oy, &ctx->sx,
tty_window_offset(&c->tty, ctx->lines, &ctx->ox, &ctx->oy, &ctx->sx,
&ctx->sy);

log_debug("%s: %s @%u ox=%u oy=%u sx=%u sy=%u %u/%d", __func__, c->name,
Expand Down
4 changes: 2 additions & 2 deletions server-client.c
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ server_client_check_mouse(struct client *c)
w = s->curw->window;

lines = status_line_size(s);
tty_window_offset(&c->tty, w, lines, &m->ox, &m->oy, &sx, &sy);
tty_window_offset(&c->tty, lines, &m->ox, &m->oy, &sx, &sy);

log_debug("mouse window @%u at %u,%u (%ux%u)", w->id, m->ox,
m->oy, sx, sy);
Expand Down Expand Up @@ -1247,7 +1247,7 @@ server_client_reset_state(struct client *c)
/* Move cursor to pane cursor and offset. */
cursor = 0;
lines = status_line_size(c->session);
tty_window_offset(&c->tty, w, lines, &ox, &oy, &sx, &sy);
tty_window_offset(&c->tty, lines, &ox, &oy, &sx, &sy);
if (wp->xoff + s->cx >= ox && wp->xoff + s->cx <= ox + sx &&
wp->yoff + s->cy >= oy && wp->yoff + s->cy <= oy + sy) {
cursor = 1;
Expand Down
6 changes: 3 additions & 3 deletions tmux.h
Original file line number Diff line number Diff line change
Expand Up @@ -1660,9 +1660,9 @@ struct environ *environ_for_session(struct session *, int);

/* tty.c */
void tty_create_log(void);
int tty_window_bigger(struct tty *, struct window *, u_int);
int tty_window_offset(struct tty *, struct window *, u_int, u_int *,
u_int *, u_int *, u_int *);
int tty_window_bigger(struct tty *, u_int);
int tty_window_offset(struct tty *, u_int, u_int *, u_int *, u_int *,
u_int *);
void tty_check_offset(struct window_pane *);
u_int tty_status_lines(struct client *);
void tty_raw(struct tty *, const char *);
Expand Down
17 changes: 9 additions & 8 deletions tty.c
Original file line number Diff line number Diff line change
Expand Up @@ -701,20 +701,23 @@ tty_repeat_space(struct tty *tty, u_int n)

/* Is this window bigger than the terminal? */
int
tty_window_bigger(struct tty *tty, struct window *w, u_int lines)
tty_window_bigger(struct tty *tty, u_int lines)
{
struct window *w = tty->client->session->curw->window;

return (tty->sx < w->sx || tty->sy - lines < w->sy);
}

/* What offset should this window be drawn at? */
int
tty_window_offset(struct tty *tty, struct window *w, u_int lines, u_int *ox,
u_int *oy, u_int *sx, u_int *sy)
tty_window_offset(struct tty *tty, u_int lines, u_int *ox, u_int *oy, u_int *sx,
u_int *sy)
{
struct window *w = tty->client->session->curw->window;
struct window_pane *wp = w->active;
u_int cx, cy;

if (!tty_window_bigger(tty, w, lines)) {
if (!tty_window_bigger(tty, lines)) {
*ox = 0;
*oy = 0;
*sx = w->sx;
Expand Down Expand Up @@ -754,20 +757,18 @@ tty_window_offset(struct tty *tty, struct window *w, u_int lines, u_int *ox,
void
tty_check_offset(struct window_pane *wp)
{
struct window *w;
struct client *c;
u_int lines, ox, oy, sx, sy;

if (wp == NULL)
return;
w = wp->window;

TAILQ_FOREACH(c, &clients, entry) {
if (!tty_client_ready(c, wp))
continue;

lines = tty_status_lines(c);
if (!tty_window_offset(&c->tty, w, lines, &ox, &oy, &sx, &sy))
if (!tty_window_offset(&c->tty, lines, &ox, &oy, &sx, &sy))
continue;
if (ox == c->tty.last_ox && oy == c->tty.last_oy)
continue;
Expand Down Expand Up @@ -1326,7 +1327,7 @@ tty_write(void (*cmdfn)(struct tty *, const struct tty_ctx *),
continue;
lines = tty_status_lines(c);

ctx->bigger = tty_window_offset(&c->tty, w, lines, &ctx->ox,
ctx->bigger = tty_window_offset(&c->tty, lines, &ctx->ox,
&ctx->oy, &ctx->sx, &ctx->sy);

ctx->xoff = wp->xoff;
Expand Down

0 comments on commit fff1d60

Please sign in to comment.