aboutsummaryrefslogtreecommitdiff
path: root/tty.c
diff options
context:
space:
mode:
authorTiago Cunha <tcunha@gmx.com>2010-06-06 00:30:34 +0000
committerTiago Cunha <tcunha@gmx.com>2010-06-06 00:30:34 +0000
commit650320718508881ab2f518ae289e1dfd8fcc0c8b (patch)
treed806554a296e7eff113968f86206abd35f83bf9b /tty.c
parent3bba40160931bdad2ad8cd5168a42239477cbe99 (diff)
downloadrtmux-650320718508881ab2f518ae289e1dfd8fcc0c8b.tar.gz
rtmux-650320718508881ab2f518ae289e1dfd8fcc0c8b.tar.bz2
rtmux-650320718508881ab2f518ae289e1dfd8fcc0c8b.zip
Sync OpenBSD patchset 716:
Fix problems with window sizing seen by Raghavendra D Prabhu when starting tmux from .xinitrc. One of the very few things the server relies on the client for now is to pass through a message on SIGWINCH, but there is a condition where potentially a SIGWINCH may be lost during the transition from unattached (main.c) to attached (client.c). So trigger a size change immediately after the client installs its SIGWINCH handler. Also, when the terminal is resized, reset the scroll region and cursor position. Previously, we were clearing our saved idea of these, but in fact some terminals do not reset them on resize, so this caused problems during redraw. While here make a resize to the same size not cause a redraw and rename the tmux.out output log file to include the tmux PID.
Diffstat (limited to 'tty.c')
-rw-r--r--tty.c39
1 files changed, 30 insertions, 9 deletions
diff --git a/tty.c b/tty.c
index 6c055d15..3814dde7 100644
--- a/tty.c
+++ b/tty.c
@@ -1,4 +1,4 @@
-/* $Id: tty.c,v 1.191 2010-06-06 00:27:08 tcunha Exp $ */
+/* $Id: tty.c,v 1.192 2010-06-06 00:30:34 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -73,34 +73,55 @@ tty_init(struct tty *tty, int fd, char *term)
tty->term_flags = 0;
}
-void
+int
tty_resize(struct tty *tty)
{
struct winsize ws;
+ u_int sx, sy;
if (ioctl(tty->fd, TIOCGWINSZ, &ws) != -1) {
- tty->sx = ws.ws_col;
- tty->sy = ws.ws_row;
+ sx = ws.ws_col;
+ if (sx == 0)
+ sx = 80;
+ sy = ws.ws_row;
+ if (sy == 0)
+ sy = 24;
+ } else {
+ sx = 80;
+ sy = 24;
}
- if (tty->sx == 0)
- tty->sx = 80;
- if (tty->sy == 0)
- tty->sy = 24;
+ if (sx == tty->sx && sy == tty->sy)
+ return (0);
+ tty->sx = sx;
+ tty->sy = sy;
tty->cx = UINT_MAX;
tty->cy = UINT_MAX;
tty->rupper = UINT_MAX;
tty->rlower = UINT_MAX;
+
+ /*
+ * If the terminal has been started, reset the actual scroll region and
+ * cursor position, as this may not have happened.
+ */
+ if (tty->flags & TTY_STARTED) {
+ tty_cursor(tty, 0, 0);
+ tty_region(tty, 0, tty->sy - 1);
+ }
+
+ return (1);
}
int
tty_open(struct tty *tty, const char *overrides, char **cause)
{
+ char out[64];
int fd;
if (debug_level > 3) {
- fd = open("tmux.out", O_WRONLY|O_CREAT|O_TRUNC, 0644);
+ xsnprintf(out, sizeof out, "tmux-out-%ld.log", (long) getpid());
+ fd = open(out, O_WRONLY|O_CREAT|O_TRUNC, 0644);
if (fd != -1 && fcntl(fd, F_SETFD, FD_CLOEXEC) == -1)
fatal("fcntl failed");
tty->log_fd = fd;