Turn cursor off during redraw, pointed out by George Nachman.
authornicm <nicm@openbsd.org>
Wed, 6 May 2015 07:52:06 +0000 (07:52 +0000)
committernicm <nicm@openbsd.org>
Wed, 6 May 2015 07:52:06 +0000 (07:52 +0000)
usr.bin/tmux/server-client.c
usr.bin/tmux/tty.c

index c126fc3..aea57e5 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: server-client.c,v 1.136 2015/04/25 18:33:59 nicm Exp $ */
+/* $OpenBSD: server-client.c,v 1.137 2015/05/06 07:52:06 nicm Exp $ */
 
 /*
  * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -875,15 +875,13 @@ void
 server_client_check_redraw(struct client *c)
 {
        struct session          *s = c->session;
+       struct tty              *tty = &c->tty;
        struct window_pane      *wp;
        int                      flags, redraw;
 
        if (c->flags & (CLIENT_CONTROL|CLIENT_SUSPENDED))
                return;
 
-       flags = c->tty.flags & TTY_FREEZE;
-       c->tty.flags &= ~TTY_FREEZE;
-
        if (c->flags & (CLIENT_REDRAW|CLIENT_STATUS)) {
                if (options_get_number(&s->options, "set-titles"))
                        server_client_set_title(c);
@@ -898,27 +896,39 @@ server_client_check_redraw(struct client *c)
                        c->flags &= ~CLIENT_STATUS;
        }
 
+       flags = tty->flags & (TTY_FREEZE|TTY_NOCURSOR);
+       tty->flags = (tty->flags & ~TTY_FREEZE) | TTY_NOCURSOR;
+
        if (c->flags & CLIENT_REDRAW) {
+               tty_update_mode(tty, tty->mode, NULL);
                screen_redraw_screen(c, 1, 1, 1);
                c->flags &= ~(CLIENT_STATUS|CLIENT_BORDERS);
        } else if (c->flags & CLIENT_REDRAWWINDOW) {
+               tty_update_mode(tty, tty->mode, NULL);
                TAILQ_FOREACH(wp, &c->session->curw->window->panes, entry)
                        screen_redraw_pane(c, wp);
                c->flags &= ~CLIENT_REDRAWWINDOW;
        } else {
                TAILQ_FOREACH(wp, &c->session->curw->window->panes, entry) {
-                       if (wp->flags & PANE_REDRAW)
+                       if (wp->flags & PANE_REDRAW) {
+                               tty_update_mode(tty, tty->mode, NULL);
                                screen_redraw_pane(c, wp);
+                       }
                }
        }
 
-       if (c->flags & CLIENT_BORDERS)
+       if (c->flags & CLIENT_BORDERS) {
+               tty_update_mode(tty, tty->mode, NULL);
                screen_redraw_screen(c, 0, 0, 1);
+       }
 
-       if (c->flags & CLIENT_STATUS)
+       if (c->flags & CLIENT_STATUS) {
+               tty_update_mode(tty, tty->mode, NULL);
                screen_redraw_screen(c, 0, 1, 0);
+       }
 
-       c->tty.flags |= flags;
+       tty->flags = (tty->flags & ~(TTY_FREEZE|TTY_NOCURSOR)) | flags;
+       tty_update_mode(tty, tty->mode, NULL);
 
        c->flags &= ~(CLIENT_REDRAW|CLIENT_STATUS|CLIENT_BORDERS);
 }
index 4b27e41..cb04de9 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty.c,v 1.180 2015/04/29 15:59:08 nicm Exp $ */
+/* $OpenBSD: tty.c,v 1.181 2015/05/06 07:52:06 nicm Exp $ */
 
 /*
  * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -500,7 +500,7 @@ tty_update_mode(struct tty *tty, int mode, struct screen *s)
 {
        int     changed;
 
-       if (strcmp(s->ccolour, tty->ccolour))
+       if (s != NULL && strcmp(s->ccolour, tty->ccolour))
                tty_force_cursor_colour(tty, s->ccolour);
 
        if (tty->flags & TTY_NOCURSOR)
@@ -517,7 +517,7 @@ tty_update_mode(struct tty *tty, int mode, struct screen *s)
                } else
                        tty_putcode(tty, TTYC_CIVIS);
        }
-       if (tty->cstyle != s->cstyle) {
+       if (s != NULL && tty->cstyle != s->cstyle) {
                if (tty_term_has(tty->term, TTYC_SS)) {
                        if (s->cstyle == 0 &&
                            tty_term_has(tty->term, TTYC_SE))
@@ -667,8 +667,11 @@ tty_draw_line(struct tty *tty, const struct window_pane *wp,
        struct grid_cell         tmpgc;
        struct utf8_data         ud;
        u_int                    i, sx;
+       int                      flags;
 
-       tty_update_mode(tty, tty->mode & ~MODE_CURSOR, s);
+       flags = tty->flags & TTY_NOCURSOR;
+       tty->flags |= TTY_NOCURSOR;
+       tty_update_mode(tty, tty->mode, s);
 
        sx = screen_size_x(s);
        if (sx > s->grid->linedata[s->grid->hsize + py].cellsize)
@@ -703,18 +706,20 @@ tty_draw_line(struct tty *tty, const struct window_pane *wp,
                        tty_cell(tty, gc, wp);
        }
 
-       if (sx >= tty->sx) {
-               tty_update_mode(tty, tty->mode, s);
-               return;
+       if (sx < tty->sx) {
+               tty_attributes(tty, &grid_default_cell, wp);
+
+               tty_cursor(tty, ox + sx, oy + py);
+               if (sx != screen_size_x(s) &&
+                   ox + screen_size_x(s) >= tty->sx &&
+                   tty_term_has(tty->term, TTYC_EL) &&
+                   !tty_fake_bce(tty, wp))
+                       tty_putcode(tty, TTYC_EL);
+               else
+                       tty_repeat_space(tty, screen_size_x(s) - sx);
        }
-       tty_attributes(tty, &grid_default_cell, wp);
 
-       tty_cursor(tty, ox + sx, oy + py);
-       if (sx != screen_size_x(s) && ox + screen_size_x(s) >= tty->sx &&
-           tty_term_has(tty->term, TTYC_EL) && !tty_fake_bce(tty, wp))
-               tty_putcode(tty, TTYC_EL);
-       else
-               tty_repeat_space(tty, screen_size_x(s) - sx);
+       tty->flags = (tty->flags & ~TTY_NOCURSOR) | flags;
        tty_update_mode(tty, tty->mode, s);
 }