diff options
author | Kyle Evans <kevans@FreeBSD.org> | 2020-12-31 16:50:43 +0000 |
---|---|---|
committer | Kyle Evans <kevans@FreeBSD.org> | 2020-12-31 17:10:11 +0000 |
commit | c4a0333b55e08f38985828a3a2d3ee533325c568 (patch) | |
tree | 2be05ffc84f4585f3ff00e305885989226631d60 /sys/dev/vt | |
parent | be46634337248029333a434c235c8424279b30b4 (diff) | |
download | src-c4a0333b55e08f38985828a3a2d3ee533325c568.tar.gz src-c4a0333b55e08f38985828a3a2d3ee533325c568.zip |
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
Diffstat (limited to 'sys/dev/vt')
-rw-r--r-- | sys/dev/vt/vt.h | 1 | ||||
-rw-r--r-- | sys/dev/vt/vt_core.c | 7 |
2 files changed, 8 insertions, 0 deletions
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 |