From d919fa1ed0ea3b167ffc811abba26a2dbcd20631 Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 5 Jun 2020 11:20:51 +0000 Subject: Change how panes are resized so that the code is clearer and if the pane is resized multiple times during one event loop, it is forced to resize at the end. Also don't zoom/unzoom in switch-client if the pane hasn't changed. GitHub issue 2260. --- window.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'window.c') diff --git a/window.c b/window.c index 020ae4bf..523e9913 100644 --- a/window.c +++ b/window.c @@ -436,14 +436,21 @@ window_resize(struct window *w, u_int sx, u_int sy, int xpixel, int ypixel) } void -window_pane_send_resize(struct window_pane *wp, int yadjust) +window_pane_send_resize(struct window_pane *wp, int force) { struct window *w = wp->window; struct winsize ws; - u_int sy = wp->sy + yadjust; + u_int sy; if (wp->fd == -1) return; + + if (!force) + sy = wp->sy; + else if (wp->sy <= 1) + sy = wp->sy + 1; + else + sy = wp->sy - 1; log_debug("%s: %%%u resize to %u,%u", __func__, wp->id, wp->sx, sy); memset(&ws, 0, sizeof ws); @@ -877,8 +884,8 @@ window_pane_create(struct window *w, u_int sx, u_int sy, u_int hlimit) wp->xoff = 0; wp->yoff = 0; - wp->sx = wp->osx = sx; - wp->sy = wp->osx = sy; + wp->sx = sx; + wp->sy = sy; wp->pipe_fd = -1; wp->pipe_event = NULL; @@ -918,6 +925,8 @@ window_pane_destroy(struct window_pane *wp) if (event_initialized(&wp->resize_timer)) event_del(&wp->resize_timer); + if (event_initialized(&wp->force_timer)) + event_del(&wp->force_timer); RB_REMOVE(window_pane_tree, &all_window_panes, wp); @@ -998,7 +1007,14 @@ window_pane_resize(struct window_pane *wp, u_int sx, u_int sy) wme = TAILQ_FIRST(&wp->modes); if (wme != NULL && wme->mode->resize != NULL) wme->mode->resize(wme, sx, sy); - wp->flags |= (PANE_RESIZE|PANE_RESIZED); + + /* + * If the pane has already been resized, set the force flag and make + * the application resize twice to force it to redraw. + */ + if (wp->flags & PANE_RESIZE) + wp->flags |= PANE_RESIZEFORCE; + wp->flags |= PANE_RESIZE; } void -- cgit