Skip to content

Commit

Permalink
vt(4): Always call vt_window_switch() in vtterm_cnungrab()
Browse files Browse the repository at this point in the history
[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
  • Loading branch information
dumbbell committed Nov 24, 2023
1 parent 16b13bd commit f18b3ce
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions sys/dev/vt/vt_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down

0 comments on commit f18b3ce

Please sign in to comment.