summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2013-03-24 09:25:05 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2013-03-24 09:25:05 +0000
commit9d92c6fa8acb67c31ebe1276c3d1061f614a4558 (patch)
tree1eb24dce40b111df4ce537cae4c74c9598cd22f2 /usr.bin
parent1cc0e255727374e2d8669d29c7f3ce996a3a8820 (diff)
Do pane resize ioctls once at the end of the server loop rather than
immediately.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tmux/server-client.c36
-rw-r--r--usr.bin/tmux/tmux.h3
-rw-r--r--usr.bin/tmux/window.c11
3 files changed, 37 insertions, 13 deletions
diff --git a/usr.bin/tmux/server-client.c b/usr.bin/tmux/server-client.c
index 08f387b2e1e..50d3d48780e 100644
--- a/usr.bin/tmux/server-client.c
+++ b/usr.bin/tmux/server-client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server-client.c,v 1.91 2013/03/24 09:18:16 nicm Exp $ */
+/* $OpenBSD: server-client.c,v 1.92 2013/03/24 09:25:04 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -17,6 +17,7 @@
*/
#include <sys/types.h>
+#include <sys/ioctl.h>
#include <event.h>
#include <fcntl.h>
@@ -29,6 +30,7 @@
#include "tmux.h"
void server_client_check_focus(struct window_pane *);
+void server_client_check_resize(struct window_pane *);
void server_client_check_mouse(struct client *, struct window_pane *);
void server_client_repeat_timer(int, short, void *);
void server_client_check_exit(struct client *);
@@ -496,7 +498,7 @@ server_client_loop(void)
/*
* Any windows will have been redrawn as part of clients, so clear
- * their flags now. Also check and update pane focus.
+ * their flags now. Also check pane focus and resize.
*/
for (i = 0; i < ARRAY_LENGTH(&windows); i++) {
w = ARRAY_ITEM(&windows, i);
@@ -506,11 +508,41 @@ server_client_loop(void)
w->flags &= ~WINDOW_REDRAW;
TAILQ_FOREACH(wp, &w->panes, entry) {
server_client_check_focus(wp);
+ server_client_check_resize(wp);
wp->flags &= ~PANE_REDRAW;
}
}
}
+/* Check if pane should be resized. */
+void
+server_client_check_resize(struct window_pane *wp)
+{
+ struct winsize ws;
+
+ if (wp->fd == -1 || !(wp->flags & PANE_RESIZE))
+ 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
+ * resizing; don't know why this happens, can't reproduce on
+ * other platforms and ignoring it doesn't seem to cause any
+ * issues.
+ */
+ if (errno != EINVAL)
+#endif
+ fatal("ioctl failed");
+ }
+
+ wp->flags &= ~PANE_RESIZE;
+}
+
/* Check whether pane should be focused. */
void
server_client_check_focus(struct window_pane *wp)
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index c654f276e09..3f69da4fd13 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.393 2013/03/24 09:18:16 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.394 2013/03/24 09:25:04 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -932,6 +932,7 @@ struct window_pane {
#define PANE_REDRAW 0x1
#define PANE_DROP 0x2
#define PANE_FOCUSED 0x4
+#define PANE_RESIZE 0x8
char *cmd;
char *shell;
diff --git a/usr.bin/tmux/window.c b/usr.bin/tmux/window.c
index 8d219ce9cc3..f2e7c7dda74 100644
--- a/usr.bin/tmux/window.c
+++ b/usr.bin/tmux/window.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: window.c,v 1.91 2013/03/24 09:21:27 nicm Exp $ */
+/* $OpenBSD: window.c,v 1.92 2013/03/24 09:25:04 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -854,23 +854,14 @@ window_pane_error_callback(
void
window_pane_resize(struct window_pane *wp, u_int sx, u_int sy)
{
- struct winsize ws;
-
if (sx == wp->sx && sy == wp->sy)
return;
wp->sx = sx;
wp->sy = sy;
- memset(&ws, 0, sizeof ws);
- ws.ws_col = sx;
- ws.ws_row = sy;
-
screen_resize(&wp->base, sx, sy, wp->saved_grid == NULL);
if (wp->mode != NULL)
wp->mode->resize(wp, sx, sy);
-
- if (wp->fd != -1 && ioctl(wp->fd, TIOCSWINSZ, &ws) == -1)
- fatal("ioctl failed");
}
/*