From owner-svn-src-head@freebsd.org Sat Aug 19 23:13:35 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 758FADC635B; Sat, 19 Aug 2017 23:13:35 +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 4F36F6930B; Sat, 19 Aug 2017 23:13:35 +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 v7JNDYo2076456; Sat, 19 Aug 2017 23:13:34 GMT (envelope-from bde@FreeBSD.org) Received: (from bde@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7JNDYfo076452; Sat, 19 Aug 2017 23:13:34 GMT (envelope-from bde@FreeBSD.org) Message-Id: <201708192313.v7JNDYfo076452@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bde set sender to bde@FreeBSD.org using -f From: Bruce Evans Date: Sat, 19 Aug 2017 23:13:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r322709 - in head/sys: dev/syscons sys X-SVN-Group: head X-SVN-Commit-Author: bde X-SVN-Commit-Paths: in head/sys: dev/syscons sys X-SVN-Commit-Revision: 322709 X-SVN-Commit-Repository: base 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: Sat, 19 Aug 2017 23:13:35 -0000 Author: bde Date: Sat Aug 19 23:13:33 2017 New Revision: 322709 URL: https://svnweb.freebsd.org/changeset/base/322709 Log: Fix setting of defaults for the text cursor. There was already a per-vty defaults field, but it was useless since it was only initialized when propagating the global settings and thus no different from the current global settings and not per-vty. The global defaults field was also invariant after boot time, but not quite so useless. Fix this by adding a second selection bit the the control flags of the relevant ioctl(). vidcontrol doesn't support this yet. Setting either default propagates the change to the current setting for the same level and then to all lower levels. Improve the 3-way escape sequence used by termcap to control the cursor. The "normal" (ve) case has always used reset, so the user could set it to anything, but since the reset is to a global value this is not very useful, especially since the "very visible" (vs) case doesn't reset but inconsistently forces to a blinking block. Change vs to first reset and then XOR the blinking bit so that it is predictably different from ve. Modified: head/sys/dev/syscons/scterm-teken.c head/sys/dev/syscons/syscons.c head/sys/sys/consio.h Modified: head/sys/dev/syscons/scterm-teken.c ============================================================================== --- head/sys/dev/syscons/scterm-teken.c Sat Aug 19 21:40:42 2017 (r322708) +++ head/sys/dev/syscons/scterm-teken.c Sat Aug 19 23:13:33 2017 (r322709) @@ -684,7 +684,6 @@ scteken_param(void *arg, int cmd, unsigned int value) static int tcattrs[] = { CONS_RESET_CURSOR | CONS_LOCAL_CURSOR, /* normal */ CONS_HIDDEN_CURSOR | CONS_LOCAL_CURSOR, /* invisible */ - CONS_BLINK_CURSOR | CONS_LOCAL_CURSOR, /* very visible */ }; scr_stat *scp = arg; int flags, n, v0, v1, v2; @@ -727,6 +726,13 @@ scteken_param(void *arg, int cmd, unsigned int value) case TP_SETLOCALCURSOR: if (value < sizeof(tcattrs) / sizeof(tcattrs[0])) sc_change_cursor_shape(scp, tcattrs[value], -1, -1); + else if (value == 2) { + sc_change_cursor_shape(scp, + CONS_RESET_CURSOR | CONS_LOCAL_CURSOR, -1, -1); + flags = scp->base_curs_attr.flags ^ CONS_BLINK_CURSOR; + sc_change_cursor_shape(scp, + flags | CONS_LOCAL_CURSOR, -1, -1); + } break; case TP_SHOWCURSOR: if (value != 0) Modified: head/sys/dev/syscons/syscons.c ============================================================================== --- head/sys/dev/syscons/syscons.c Sat Aug 19 21:40:42 2017 (r322708) +++ head/sys/dev/syscons/syscons.c Sat Aug 19 23:13:33 2017 (r322709) @@ -943,13 +943,19 @@ sctty_ioctl(struct tty *tp, u_long cmd, caddr_t data, return 0; case CONS_GETCURSORSHAPE: /* get cursor shape (new interface) */ - switch (((int *)data)[0] & CONS_LOCAL_CURSOR) { + switch (((int *)data)[0] & (CONS_DEFAULT_CURSOR | CONS_LOCAL_CURSOR)) { case 0: cap = &sc->curs_attr; break; case CONS_LOCAL_CURSOR: cap = &scp->base_curs_attr; break; + case CONS_DEFAULT_CURSOR: + cap = &sc->dflt_curs_attr; + break; + case CONS_DEFAULT_CURSOR | CONS_LOCAL_CURSOR: + cap = &scp->dflt_curs_attr; + break; } ((int *)data)[1] = cap->base; ((int *)data)[2] = cap->height; @@ -3030,7 +3036,10 @@ change_cursor_shape(scr_stat *scp, int flags, int base if (flags & CONS_RESET_CURSOR) scp->base_curs_attr = scp->dflt_curs_attr; - else + else if (flags & CONS_DEFAULT_CURSOR) { + sc_adjust_ca(&scp->dflt_curs_attr, flags, base, height); + scp->base_curs_attr = scp->dflt_curs_attr; + } else sc_adjust_ca(&scp->base_curs_attr, flags, base, height); if ((scp == scp->sc->cur_scp) && !ISGRAPHSC(scp)) { @@ -3062,7 +3071,10 @@ sc_change_cursor_shape(scr_stat *scp, int flags, int b sc = scp->sc; if (flags & CONS_RESET_CURSOR) sc->curs_attr = sc->dflt_curs_attr; - else + else if (flags & CONS_DEFAULT_CURSOR) { + sc_adjust_ca(&sc->dflt_curs_attr, flags, base, height); + sc->curs_attr = sc->dflt_curs_attr; + } else sc_adjust_ca(&sc->curs_attr, flags, base, height); for (i = sc->first_vty; i < sc->first_vty + sc->vtys; ++i) { Modified: head/sys/sys/consio.h ============================================================================== --- head/sys/sys/consio.h Sat Aug 19 21:40:42 2017 (r322708) +++ head/sys/sys/consio.h Sat Aug 19 23:13:33 2017 (r322709) @@ -187,6 +187,7 @@ typedef struct mouse_info mouse_info_t; #define CONS_HIDDEN_CURSOR (1 << 2) #define CONS_CURSOR_ATTRS (CONS_BLINK_CURSOR | CONS_CHAR_CURSOR | \ CONS_HIDDEN_CURSOR) +#define CONS_DEFAULT_CURSOR (1 << 28) #define CONS_SHAPEONLY_CURSOR (1 << 29) #define CONS_RESET_CURSOR (1 << 30) #define CONS_LOCAL_CURSOR (1U << 31)