git: f18b3ce0b7be - main - vt(4): Always call vt_window_switch() in vtterm_cnungrab()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 24 Nov 2023 17:32:00 UTC
The branch main has been updated by dumbbell:
URL: https://cgit.FreeBSD.org/src/commit/?id=f18b3ce0b7be0b24a743ec59077ca8e7929a353c
commit f18b3ce0b7be0b24a743ec59077ca8e7929a353c
Author: Jean-Sébastien Pédron <dumbbell@FreeBSD.org>
AuthorDate: 2023-11-24 17:30:35 +0000
Commit: Jean-Sébastien Pédron <dumbbell@FreeBSD.org>
CommitDate: 2023-11-24 17:31:33 +0000
vt(4): Always call vt_window_switch() in vtterm_cnungrab()
[Why]
This ensures that vtterm_cnungrab() is the mirror of vtterm_cngrab().
And the latter always call vt_window_switch() and thus the backend's
vd_postswitch().
This makes sure that whatever the backend did during vtterm_cngrab(), it
can undo it during vtterm_cnungrab().
Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D42752
---
sys/dev/vt/vt_core.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/sys/dev/vt/vt_core.c b/sys/dev/vt/vt_core.c
index bfd99665be4a..4a1031f1aa69 100644
--- a/sys/dev/vt/vt_core.c
+++ b/sys/dev/vt/vt_core.c
@@ -2046,7 +2046,7 @@ static void
vtterm_cnungrab(struct terminal *tm)
{
struct vt_device *vd;
- struct vt_window *vw;
+ struct vt_window *vw, *grabwindow;
vw = tm->tm_softc;
vd = vw->vw_device;
@@ -2055,10 +2055,19 @@ vtterm_cnungrab(struct terminal *tm)
if (vtterm_cnungrab_noswitch(vd, vw) != 0)
return;
- if (!cold && vd->vd_grabwindow != vw)
- vt_window_switch(vd->vd_grabwindow);
-
+ /*
+ * We set `vd_grabwindow` to NULL before calling vt_window_switch()
+ * because it allows the underlying vt(4) backend to distinguish a
+ * "grab" from an "ungrab" of the console.
+ *
+ * This is used by `vt_drmfb` in drm-kmod to call either
+ * fb_debug_enter() or fb_debug_leave() appropriately.
+ */
+ grabwindow = vd->vd_grabwindow;
vd->vd_grabwindow = NULL;
+
+ if (!cold)
+ vt_window_switch(grabwindow);
}
static void