Update of /cvsroot/tmux/tmux
In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv8499

Modified Files:
        client.c server-client.c tmux.h tty.c 
Log Message:
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.


Index: client.c
===================================================================
RCS file: /cvsroot/tmux/tmux/client.c,v
retrieving revision 1.93
retrieving revision 1.94
diff -u -d -r1.93 -r1.94
--- client.c    6 Jun 2010 00:25:47 -0000       1.93
+++ client.c    6 Jun 2010 00:30:34 -0000       1.94
@@ -180,6 +180,13 @@
        set_signals(client_signal);
 
        /*
+        * Send a resize message immediately in case the terminal size has
+        * changed between the identify message to the server and the MSG_READY
+        * telling us to move into the client code.
+        */
+        client_write_server(MSG_RESIZE, NULL, 0);
+
+       /*
         * imsg_read in the first client poll loop (before the terminal has
         * been initialised) may have read messages into the buffer after the
         * MSG_READY switched to here. Process anything outstanding now to

Index: tty.c
===================================================================
RCS file: /cvsroot/tmux/tmux/tty.c,v
retrieving revision 1.191
retrieving revision 1.192
diff -u -d -r1.191 -r1.192
--- tty.c       6 Jun 2010 00:27:08 -0000       1.191
+++ tty.c       6 Jun 2010 00:30:34 -0000       1.192
@@ -73,34 +73,55 @@
        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;

Index: tmux.h
===================================================================
RCS file: /cvsroot/tmux/tmux/tmux.h,v
retrieving revision 1.560
retrieving revision 1.561
diff -u -d -r1.560 -r1.561
--- tmux.h      6 Jun 2010 00:23:44 -0000       1.560
+++ tmux.h      6 Jun 2010 00:30:34 -0000       1.561
@@ -1354,7 +1354,7 @@
 void   tty_putc(struct tty *, u_char);
 void   tty_pututf8(struct tty *, const struct grid_utf8 *);
 void   tty_init(struct tty *, int, char *);
-void   tty_resize(struct tty *);
+int    tty_resize(struct tty *);
 void   tty_start_tty(struct tty *);
 void   tty_stop_tty(struct tty *);
 void   tty_set_title(struct tty *, const char *);

Index: server-client.c
===================================================================
RCS file: /cvsroot/tmux/tmux/server-client.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- server-client.c     22 May 2010 21:56:04 -0000      1.32
+++ server-client.c     6 Jun 2010 00:30:34 -0000       1.33
@@ -560,9 +560,10 @@
                        if (datalen != 0)
                                fatalx("bad MSG_RESIZE size");
 
-                       tty_resize(&c->tty);
-                       recalculate_sizes();
-                       server_redraw_client(c);
+                       if (tty_resize(&c->tty)) {
+                               recalculate_sizes();
+                               server_redraw_client(c);
+                       }
                        break;
                case MSG_EXITING:
                        if (datalen != 0)


------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
tmux-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tmux-cvs

Reply via email to