aboutsummaryrefslogtreecommitdiff
path: root/server-client.c
diff options
context:
space:
mode:
authorThomas Adam <thomas@xteddy.org>2017-05-31 15:56:13 +0100
committerThomas Adam <thomas@xteddy.org>2017-05-31 15:56:13 +0100
commitf17ecaa49544509e93716a84b6510990ed90ceca (patch)
tree6b89857ce59fc9330c136961defdcc0923cbff40 /server-client.c
parent9c4d0d454aa81b9587ed724e0f87395b1791ce2f (diff)
parentd60663ea8664d1c71def883bd64d97af3f791f89 (diff)
downloadrtmux-f17ecaa49544509e93716a84b6510990ed90ceca.tar.gz
rtmux-f17ecaa49544509e93716a84b6510990ed90ceca.tar.bz2
rtmux-f17ecaa49544509e93716a84b6510990ed90ceca.zip
Merge branch 'obsd-master'
Conflicts: Makefile.am cfg.c server-client.c
Diffstat (limited to 'server-client.c')
-rw-r--r--server-client.c53
1 files changed, 47 insertions, 6 deletions
diff --git a/server-client.c b/server-client.c
index 6716b503..aaedebcf 100644
--- a/server-client.c
+++ b/server-client.c
@@ -1036,6 +1036,44 @@ server_client_loop(void)
}
}
+/* Check if we need to force a resize. */
+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
+ * (that is, to the same size the application currently thinks it is),
+ * tmux may have gone through several resizes internally and thrown
+ * away parts of the screen. So we need the application to actually
+ * redraw even though its final size has not changed.
+ */
+
+ if (wp->flags & PANE_RESIZEFORCE) {
+ wp->flags &= ~PANE_RESIZEFORCE;
+ return (0);
+ }
+
+ if (wp->sx != wp->osx ||
+ wp->sy != wp->osy ||
+ wp->sx <= 1 ||
+ wp->sy <= 1)
+ return (0);
+
+ memset(&ws, 0, sizeof ws);
+ ws.ws_col = wp->sx;
+ ws.ws_row = wp->sy - 1;
+ if (ioctl(wp->fd, TIOCSWINSZ, &ws) == -1)
+ fatal("ioctl failed");
+ log_debug("%s: %%%u forcing resize", __func__, wp->id);
+
+ evtimer_add(&wp->resize_timer, &tv);
+ wp->flags |= PANE_RESIZEFORCE;
+ return (1);
+}
+
/* Resize timer event. */
static void
server_client_resize_event(__unused int fd, __unused short events, void *data)
@@ -1047,12 +1085,12 @@ server_client_resize_event(__unused int fd, __unused short events, void *data)
if (!(wp->flags & PANE_RESIZE))
return;
+ if (server_client_resize_force(wp))
+ return;
memset(&ws, 0, sizeof ws);
ws.ws_col = wp->sx;
ws.ws_row = wp->sy;
-
- if (ioctl(wp->fd, TIOCSWINSZ, &ws) == -1) {
#ifdef __sun
/*
* Some versions of Solaris apparently can return an error when
@@ -1066,6 +1104,9 @@ server_client_resize_event(__unused int fd, __unused short events, void *data)
}
wp->flags &= ~PANE_RESIZE;
+
+ wp->osx = wp->sx;
+ wp->osy = wp->sy;
}
/* Check if pane should be resized. */
@@ -1076,6 +1117,7 @@ server_client_check_resize(struct window_pane *wp)
if (!(wp->flags & PANE_RESIZE))
return;
+ log_debug("%s: %%%u resize to %u,%u", __func__, wp->id, wp->sx, wp->sy);
if (!event_initialized(&wp->resize_timer))
evtimer_set(&wp->resize_timer, server_client_resize_event, wp);
@@ -1436,10 +1478,9 @@ server_client_dispatch(struct imsg *imsg, void *arg)
if (c->flags & CLIENT_CONTROL)
break;
- if (tty_resize(&c->tty)) {
- recalculate_sizes();
- server_redraw_client(c);
- }
+ tty_resize(&c->tty);
+ recalculate_sizes();
+ server_redraw_client(c);
if (c->session != NULL)
notify_client("client-resized", c);
break;