vt(4): Change the terminal and buffer sizes, even without a font

This fixes a bug where scroll lock would not work for tty #0 when using
vt_vga's textmode. The reason was that this window is created with a
static 256x100 buffer, larger than the real size of 80x25.

Now, in vt_change_font() and vt_compute_drawable_area(), we still
perform operations even of the window has no font loaded (this is the
case in textmode here vw->vw_font == NULL). One of these operation
resizes the buffer accordingly.

In vt_compute_drawable_area(), we take the terminal size as is (ie.
80x25) for the drawable area.

The font argument to vt_set_border() is removed (it was never used) and
the code now uses the computed drawable area instead of re-doing its own
calculation.

Reported by:	Harald Schmalzbauer <h.schmalzbauer_omnilan.de>
Tested by:	Harald Schmalzbauer <h.schmalzbauer_omnilan.de>
MFC after:	3 days
This commit is contained in:
Jean-Sébastien Pédron 2014-09-08 07:37:03 +00:00
parent 9dd099b274
commit 313ef9368f
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=271250

View File

@ -430,10 +430,16 @@ vt_compute_drawable_area(struct vt_window *vw)
struct vt_device *vd;
struct vt_font *vf;
if (vw->vw_font == NULL)
return;
vd = vw->vw_device;
if (vw->vw_font == NULL) {
vw->vw_draw_area.tr_begin.tp_col = 0;
vw->vw_draw_area.tr_begin.tp_row = 0;
vw->vw_draw_area.tr_end.tp_col = vd->vd_width;
vw->vw_draw_area.tr_end.tp_row = vd->vd_height;
return;
}
vf = vw->vw_font;
/*
@ -1300,30 +1306,40 @@ vtterm_opened(struct terminal *tm, int opened)
}
static int
vt_set_border(struct vt_window *vw, struct vt_font *vf, term_color_t c)
vt_set_border(struct vt_window *vw, term_color_t c)
{
struct vt_device *vd = vw->vw_device;
int x, y, off_x, off_y;
if (vd->vd_driver->vd_drawrect == NULL)
return (ENOTSUP);
x = vd->vd_width - 1;
y = vd->vd_height - 1;
off_x = vw->vw_draw_area.tr_begin.tp_col;
off_y = vw->vw_draw_area.tr_begin.tp_row;
/* Top bar. */
if (off_y > 0)
vd->vd_driver->vd_drawrect(vd, 0, 0, x, off_y - 1, 1, c);
/* Left bar. */
if (off_x > 0)
vd->vd_driver->vd_drawrect(vd, 0, off_y, off_x - 1, y - off_y,
if (vw->vw_draw_area.tr_begin.tp_row > 0)
vd->vd_driver->vd_drawrect(vd,
0, 0,
vd->vd_width - 1, vw->vw_draw_area.tr_begin.tp_row - 1,
1, c);
/* Left bar. */
if (vw->vw_draw_area.tr_begin.tp_col > 0)
vd->vd_driver->vd_drawrect(vd,
0, 0,
vw->vw_draw_area.tr_begin.tp_col - 1, vd->vd_height - 1,
1, c);
/* Right bar. */
if (vw->vw_draw_area.tr_end.tp_col < vd->vd_width)
vd->vd_driver->vd_drawrect(vd,
vw->vw_draw_area.tr_end.tp_col - 1, 0,
vd->vd_width - 1, vd->vd_height - 1,
1, c);
/* Bottom bar. */
if (vw->vw_draw_area.tr_end.tp_row < vd->vd_height)
vd->vd_driver->vd_drawrect(vd,
0, vw->vw_draw_area.tr_end.tp_row - 1,
vd->vd_width - 1, vd->vd_height - 1,
1, c);
/* Right bar. May be 1 pixel wider than necessary due to rounding. */
vd->vd_driver->vd_drawrect(vd, x - off_x, off_y, x, y - off_y, 1, c);
/* Bottom bar. May be 1 mixel taller than necessary due to rounding. */
vd->vd_driver->vd_drawrect(vd, 0, y - off_y, x, y, 1, c);
return (0);
}
@ -1355,11 +1371,6 @@ vt_change_font(struct vt_window *vw, struct vt_font *vf)
VT_UNLOCK(vd);
return (EBUSY);
}
if (vd->vd_flags & VDF_TEXTMODE) {
/* Our device doesn't need fonts. */
VT_UNLOCK(vd);
return (ENOTTY);
}
vw->vw_flags |= VWF_BUSY;
VT_UNLOCK(vd);
@ -1374,7 +1385,7 @@ vt_change_font(struct vt_window *vw, struct vt_font *vf)
/* Actually apply the font to the current window. */
VT_LOCK(vd);
if (vw->vw_font != vf) {
if (vw->vw_font != vf && vw->vw_font != NULL && vf != NULL) {
/*
* In case vt_change_font called to update size we don't need
* to update font link.
@ -1397,7 +1408,7 @@ vt_change_font(struct vt_window *vw, struct vt_font *vf)
/* Force a full redraw the next timer tick. */
if (vd->vd_curwindow == vw) {
vt_set_border(vw, vf, TC_BLACK);
vt_set_border(vw, TC_BLACK);
vd->vd_flags |= VDF_INVALID;
vt_resume_flush_timer(vw->vw_device, 0);
}