From owner-svn-src-head@FreeBSD.ORG Sat Nov 1 17:05:17 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 791ECF59; Sat, 1 Nov 2014 17:05:17 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 647E3C9B; Sat, 1 Nov 2014 17:05:17 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sA1H5HVR030104; Sat, 1 Nov 2014 17:05:17 GMT (envelope-from dumbbell@FreeBSD.org) Received: (from dumbbell@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sA1H5GrM030099; Sat, 1 Nov 2014 17:05:16 GMT (envelope-from dumbbell@FreeBSD.org) Message-Id: <201411011705.sA1H5GrM030099@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: dumbbell set sender to dumbbell@FreeBSD.org using -f From: Jean-Sebastien Pedron Date: Sat, 1 Nov 2014 17:05:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r273932 - in head/sys: dev/vt kern sys X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 01 Nov 2014 17:05:17 -0000 Author: dumbbell Date: Sat Nov 1 17:05:15 2014 New Revision: 273932 URL: https://svnweb.freebsd.org/changeset/base/273932 Log: vt(4): Adjust the cursor position after changing the window size A new terminal_set_cursor() is added: it wraps the existing teken_set_cursor() function. In vtbuf_grow(), the cursor position is adjusted at the end of the function. In vt_change_font(), we call terminal_set_cursor() just after terminal_set_winsize_blank(), while the terminal is mute. This fixes a bug where, after loading a kernel video driver which increases the terminal window size, the cursor remains at its old position, in other words, in the middle of the display content. PR: 194421 MFC after: 1 week Modified: head/sys/dev/vt/vt_buf.c head/sys/dev/vt/vt_core.c head/sys/kern/subr_terminal.c head/sys/sys/terminal.h Modified: head/sys/dev/vt/vt_buf.c ============================================================================== --- head/sys/dev/vt/vt_buf.c Sat Nov 1 13:45:01 2014 (r273931) +++ head/sys/dev/vt/vt_buf.c Sat Nov 1 17:05:15 2014 (r273932) @@ -562,6 +562,18 @@ vtbuf_grow(struct vt_buf *vb, const term vb->vb_roffset = vb->vb_curroffset; } + /* Adjust cursor position. */ + if (vb->vb_cursor.tp_col > p->tp_col - 1) + /* + * Move cursor to the last column, in case its previous + * position is outside of the new screen area. + */ + vb->vb_cursor.tp_col = p->tp_col - 1; + + if (vb->vb_curroffset > 0 || vb->vb_cursor.tp_row > p->tp_row - 1) + /* Move cursor to the last line on the screen. */ + vb->vb_cursor.tp_row = p->tp_row - 1; + vtbuf_make_undirty(vb); VTBUF_UNLOCK(vb); Modified: head/sys/dev/vt/vt_core.c ============================================================================== --- head/sys/dev/vt/vt_core.c Sat Nov 1 13:45:01 2014 (r273931) +++ head/sys/dev/vt/vt_core.c Sat Nov 1 17:05:15 2014 (r273932) @@ -1532,6 +1532,7 @@ vt_change_font(struct vt_window *vw, str terminal_mute(tm, 1); vtbuf_grow(&vw->vw_buf, &size, vw->vw_buf.vb_history_size); terminal_set_winsize_blank(tm, &wsz, 0, NULL); + terminal_set_cursor(tm, &vw->vw_buf.vb_cursor); terminal_mute(tm, 0); /* Actually apply the font to the current window. */ Modified: head/sys/kern/subr_terminal.c ============================================================================== --- head/sys/kern/subr_terminal.c Sat Nov 1 13:45:01 2014 (r273931) +++ head/sys/kern/subr_terminal.c Sat Nov 1 17:05:15 2014 (r273932) @@ -190,6 +190,13 @@ terminal_maketty(struct terminal *tm, co } void +terminal_set_cursor(struct terminal *tm, const term_pos_t *pos) +{ + + teken_set_cursor(&tm->tm_emulator, pos); +} + +void terminal_set_winsize_blank(struct terminal *tm, const struct winsize *size, int blank, const term_attr_t *attr) { Modified: head/sys/sys/terminal.h ============================================================================== --- head/sys/sys/terminal.h Sat Nov 1 13:45:01 2014 (r273931) +++ head/sys/sys/terminal.h Sat Nov 1 17:05:15 2014 (r273932) @@ -207,6 +207,7 @@ struct terminal { struct terminal *terminal_alloc(const struct terminal_class *tc, void *softc); void terminal_maketty(struct terminal *tm, const char *fmt, ...); +void terminal_set_cursor(struct terminal *tm, const term_pos_t *pos); void terminal_set_winsize_blank(struct terminal *tm, const struct winsize *size, int blank, const term_attr_t *attr); void terminal_set_winsize(struct terminal *tm, const struct winsize *size);