diff options
author | dumbbell <dumbbell@FreeBSD.org> | 2014-11-01 17:05:15 +0000 |
---|---|---|
committer | dumbbell <dumbbell@FreeBSD.org> | 2014-11-01 17:05:15 +0000 |
commit | 035cb01fbbe932e0165a764ecab69cd6492d5fbc (patch) | |
tree | de2db3fcc80adf0d399fede8bc0d5457dc4e2075 /sys/dev/vt | |
parent | 120021745eb3a1c1b24fdc54769f808151deb621 (diff) | |
download | FreeBSD-src-035cb01fbbe932e0165a764ecab69cd6492d5fbc.zip FreeBSD-src-035cb01fbbe932e0165a764ecab69cd6492d5fbc.tar.gz |
vt(4): Adjust the cursor position after changing the window size
A new terminal_set_cursor() is added: it wraps the existing
teken_set_cursor() function.
In vtbuf_grow(), the cursor position is adjusted at the end of the
function. In vt_change_font(), we call terminal_set_cursor() just after
terminal_set_winsize_blank(), while the terminal is mute.
This fixes a bug where, after loading a kernel video driver which
increases the terminal window size, the cursor remains at its old
position, in other words, in the middle of the display content.
PR: 194421
MFC after: 1 week
Diffstat (limited to 'sys/dev/vt')
-rw-r--r-- | sys/dev/vt/vt_buf.c | 12 | ||||
-rw-r--r-- | sys/dev/vt/vt_core.c | 1 |
2 files changed, 13 insertions, 0 deletions
diff --git a/sys/dev/vt/vt_buf.c b/sys/dev/vt/vt_buf.c index cc23b3b..c3e639e 100644 --- a/sys/dev/vt/vt_buf.c +++ b/sys/dev/vt/vt_buf.c @@ -562,6 +562,18 @@ vtbuf_grow(struct vt_buf *vb, const term_pos_t *p, unsigned int history_size) vb->vb_roffset = vb->vb_curroffset; } + /* Adjust cursor position. */ + if (vb->vb_cursor.tp_col > p->tp_col - 1) + /* + * Move cursor to the last column, in case its previous + * position is outside of the new screen area. + */ + vb->vb_cursor.tp_col = p->tp_col - 1; + + if (vb->vb_curroffset > 0 || vb->vb_cursor.tp_row > p->tp_row - 1) + /* Move cursor to the last line on the screen. */ + vb->vb_cursor.tp_row = p->tp_row - 1; + vtbuf_make_undirty(vb); VTBUF_UNLOCK(vb); diff --git a/sys/dev/vt/vt_core.c b/sys/dev/vt/vt_core.c index 8c7d0f0..0062b0e 100644 --- a/sys/dev/vt/vt_core.c +++ b/sys/dev/vt/vt_core.c @@ -1532,6 +1532,7 @@ vt_change_font(struct vt_window *vw, struct vt_font *vf) terminal_mute(tm, 1); vtbuf_grow(&vw->vw_buf, &size, vw->vw_buf.vb_history_size); terminal_set_winsize_blank(tm, &wsz, 0, NULL); + terminal_set_cursor(tm, &vw->vw_buf.vb_cursor); terminal_mute(tm, 0); /* Actually apply the font to the current window. */ |