From owner-svn-src-head@freebsd.org Wed Apr 12 16:21:56 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C580FD3AC3F; Wed, 12 Apr 2017 16:21:56 +0000 (UTC) (envelope-from bde@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::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 A0C2F3ED; Wed, 12 Apr 2017 16:21:56 +0000 (UTC) (envelope-from bde@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v3CGLt50020618; Wed, 12 Apr 2017 16:21:55 GMT (envelope-from bde@FreeBSD.org) Received: (from bde@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v3CGLtkP020617; Wed, 12 Apr 2017 16:21:55 GMT (envelope-from bde@FreeBSD.org) Message-Id: <201704121621.v3CGLtkP020617@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bde set sender to bde@FreeBSD.org using -f From: Bruce Evans Date: Wed, 12 Apr 2017 16:21:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r316733 - head/sys/dev/syscons 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.23 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: Wed, 12 Apr 2017 16:21:56 -0000 Author: bde Date: Wed Apr 12 16:21:55 2017 New Revision: 316733 URL: https://svnweb.freebsd.org/changeset/base/316733 Log: Fix clobbering of the default attribute and the screen position in scteken_init(). Move the internals of scteken_sync() into a local function to help do this. scteken_init() reset or adjusted the default attribute and screen position at least 3 and 5 times, respectively. Warm init shouldn't do any more than reset the "input" state. (scterm-sc.c (which still works after minor editing), only resets the escape state and the saved cursor position, and then does a nearly-null sync of the current color.) This mainly broke mode changes, and was most noticeable when the background color is not teken's default (usually black). Then the screen gets cleared in the wrong color. vidcontrol restores the default normal attribute and tries to restore the default reverse attribute. vidcontrol doesn't clear the screen again after restoring the attribute(s), and it is too late to do it there without flicker. Now the default normal attribute is restored before the change affects the rendering. When the foreground color is not teken's default, clearing with the wrong attributes gave strange cursor colors for some cursor types. The default reverse attribute is not restored since it is unsupported. 2/3 of the clobbering was from 2 resetting window resizing calls. The second one is needed to restore the size, but must not reset. Window resizing also sanitizes the cursor position, and after the main reset resets the window size, the cursor row would often be adjusted from 24 to 23 if it were not already reset to 0. scteken_sync() is good for restoring the window size and the cursor position in the correct order, but was unusable at init time since scp->ts is not always initialized then. Adjust to use its internals. I didn't notice any problems from the cursor reset. The cursor should be reset, and a previous fix was to reset it consistently a little later. Doing nothing for warm init works almost as well, if not better. It is not very useful to reset the escape state for mode changes, since the reset is especially likely to be null then. The escape state is most likely to be non-initial and corrupted by its most normal uses -- sloppy non-atomic output where a context switch or just mixing stdout with stderr splits up escape sequences. Modified: head/sys/dev/syscons/scterm-teken.c Modified: head/sys/dev/syscons/scterm-teken.c ============================================================================== --- head/sys/dev/syscons/scterm-teken.c Wed Apr 12 12:34:27 2017 (r316732) +++ head/sys/dev/syscons/scterm-teken.c Wed Apr 12 16:21:55 2017 (r316733) @@ -72,6 +72,8 @@ typedef struct { static teken_stat reserved_teken_stat; +static void scteken_sync_internal(scr_stat *, teken_stat *); + static sc_term_sw_t sc_term_scteken = { { NULL, NULL }, "scteken", /* emulator name */ @@ -116,7 +118,7 @@ static int scteken_init(scr_stat *scp, void **softc, int code) { teken_stat *ts; - teken_pos_t tp; + teken_attr_t ta; if (*softc == NULL) { if (reserved_teken_stat.ts_busy) @@ -131,17 +133,16 @@ scteken_init(scr_stat *scp, void **softc ts->ts_busy = 1; /* FALLTHROUGH */ case SC_TE_WARM_INIT: + ta = *teken_get_defattr(&ts->ts_teken); teken_init(&ts->ts_teken, &scteken_funcs, scp); + teken_set_defattr(&ts->ts_teken, &ta); #ifndef TEKEN_UTF8 teken_set_8bit(&ts->ts_teken); #endif /* !TEKEN_UTF8 */ #ifdef TEKEN_CONS25 teken_set_cons25(&ts->ts_teken); #endif /* TEKEN_CONS25 */ - - tp.tp_row = scp->ysize; - tp.tp_col = scp->xsize; - teken_set_winsize(&ts->ts_teken, &tp); + scteken_sync_internal(scp, ts); break; } @@ -219,7 +220,7 @@ scteken_clear(scr_stat *scp) teken_stat *ts = scp->ts; sc_move_cursor(scp, 0, 0); - scteken_sync(scp); + scteken_sync_internal(scp, ts); sc_vtb_clear(&scp->vtb, scp->sc->scr_map[0x20], scteken_te_to_sc_attr(teken_get_curattr(&ts->ts_teken)) << 8); @@ -284,9 +285,8 @@ scteken_fkeystr(scr_stat *scp, int c) } static void -scteken_sync(scr_stat *scp) +scteken_sync_internal(scr_stat *scp, teken_stat *ts) { - teken_stat *ts = scp->ts; teken_pos_t tp; tp.tp_col = scp->xsize; @@ -298,6 +298,12 @@ scteken_sync(scr_stat *scp) } static void +scteken_sync(scr_stat *scp) +{ + scteken_sync_internal(scp, scp->ts); +} + +static void scteken_nop(void) {