From owner-dev-commits-src-main@freebsd.org Thu Dec 31 17:10:18 2020 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4F52A4C8997; Thu, 31 Dec 2020 17:10:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4D6F5k1Hztz3JSD; Thu, 31 Dec 2020 17:10:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1F90B13E50; Thu, 31 Dec 2020 17:10:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 0BVHAIk8086936; Thu, 31 Dec 2020 17:10:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 0BVHAIfK086928; Thu, 31 Dec 2020 17:10:18 GMT (envelope-from git) Date: Thu, 31 Dec 2020 17:10:18 GMT Message-Id: <202012311710.0BVHAIfK086928@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kyle Evans Subject: git: c4a0333b55e0 - main - vt: restore tty when console is ungrabbed MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kevans X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c4a0333b55e08f38985828a3a2d3ee533325c568 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "Commit messages for the main branch of the src repository." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Dec 2020 17:10:18 -0000 The branch main has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=c4a0333b55e08f38985828a3a2d3ee533325c568 commit c4a0333b55e08f38985828a3a2d3ee533325c568 Author: Kyle Evans AuthorDate: 2020-12-31 16:50:43 +0000 Commit: Kyle Evans CommitDate: 2020-12-31 17:10:11 +0000 vt: restore tty when console is ungrabbed When a break-to-debugger is triggered, kdb will grab the console and vt(4) will generally switch back to ttyv0. If one issues a continue from the debugger, then kdb will ungrab the console and the system rolls on. This change adds a perhaps minor feature: when we're down to grab == 0 and if vt actually switched away to ttyv0, switch back to the tty it was previously on before the console was grabbed. The justification behind this is that a typical flow is to work in !ttyv0 to avoid console spam while occasionally dropping to ddb to inspect system state before returning. This could easily enough be tossed behind a sysctl or something if it's not generally appreciated, but I anticipate indifference. Reviewed by: ray Differential Revision: https://reviews.freebsd.org/D27110 --- sys/dev/vt/vt.h | 1 + sys/dev/vt/vt_core.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/sys/dev/vt/vt.h b/sys/dev/vt/vt.h index 7d960f68e83f..2d671d692384 100644 --- a/sys/dev/vt/vt.h +++ b/sys/dev/vt/vt.h @@ -124,6 +124,7 @@ struct vt_device { struct vt_window *vd_windows[VT_MAXWINDOWS]; /* (c) Windows. */ struct vt_window *vd_curwindow; /* (d) Current window. */ struct vt_window *vd_savedwindow;/* (?) Saved for suspend. */ + struct vt_window *vd_grabwindow; /* (?) Saved before cngrab. */ struct vt_pastebuf vd_pastebuf; /* (?) Copy/paste buf. */ const struct vt_driver *vd_driver; /* (c) Graphics driver. */ void *vd_softc; /* (u) Driver data. */ diff --git a/sys/dev/vt/vt_core.c b/sys/dev/vt/vt_core.c index c273b703de93..2352ed823424 100644 --- a/sys/dev/vt/vt_core.c +++ b/sys/dev/vt/vt_core.c @@ -1805,6 +1805,9 @@ vtterm_cngrab(struct terminal *tm) vw = tm->tm_softc; vd = vw->vw_device; + /* To be restored after we ungrab. */ + if (vd->vd_grabwindow == NULL) + vd->vd_grabwindow = vd->vd_curwindow; if (!cold) vt_window_switch(vw); @@ -1821,10 +1824,14 @@ vtterm_cnungrab(struct terminal *tm) vw = tm->tm_softc; vd = vw->vw_device; + MPASS(vd->vd_grabwindow != NULL); if (vtterm_cnungrab_noswitch(vd, vw) != 0) return; + if (!cold && vd->vd_grabwindow != vw) + vt_window_switch(vd->vd_grabwindow); + vd->vd_grabwindow = NULL; } static void