git: c4a0333b55e0 - main - vt: restore tty when console is ungrabbed
Kyle Evans
kevans at FreeBSD.org
Thu Dec 31 17:10:18 UTC 2020
The branch main has been updated by kevans:
URL: https://cgit.FreeBSD.org/src/commit/?id=c4a0333b55e08f38985828a3a2d3ee533325c568
commit c4a0333b55e08f38985828a3a2d3ee533325c568
Author: Kyle Evans <kevans at FreeBSD.org>
AuthorDate: 2020-12-31 16:50:43 +0000
Commit: Kyle Evans <kevans at FreeBSD.org>
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
More information about the dev-commits-src-all
mailing list