diff options
author | dumbbell <dumbbell@FreeBSD.org> | 2014-08-23 07:41:08 +0000 |
---|---|---|
committer | dumbbell <dumbbell@FreeBSD.org> | 2014-08-23 07:41:08 +0000 |
commit | 261ed191628cc4d2f43b8194e2debdcf16e89a21 (patch) | |
tree | 8ab7dbb08a157445f33f6b679b8553f260f7274f | |
parent | c03089040791f74d09b3be90ab1fe6065f3c2a7f (diff) | |
download | FreeBSD-src-261ed191628cc4d2f43b8194e2debdcf16e89a21.zip FreeBSD-src-261ed191628cc4d2f43b8194e2debdcf16e89a21.tar.gz |
vt(4): Fix a crash in vt_mark_mouse_position_as_dirty() when in textmode
In textmode, no font is loaded, thus the page fault in
vt_mark_mouse_position_as_dirty() when it wants the font width/height.
For now, create a fake area for the textmode. This needs to be modified
if vt_vga gains mouse support in textmode.
While here, fix a build failure when SC_NO_CUTPASTE is defined:
vt_mark_mouse_position_as_dirty() must not be included in this case.
MFC after: 1 week
-rw-r--r-- | sys/dev/vt/vt_core.c | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/sys/dev/vt/vt_core.c b/sys/dev/vt/vt_core.c index fba3990..66f41c3 100644 --- a/sys/dev/vt/vt_core.c +++ b/sys/dev/vt/vt_core.c @@ -818,6 +818,7 @@ vt_determine_colors(term_char_t c, int cursor, } } +#ifndef SC_NO_CUTPASTE static void vt_mark_mouse_position_as_dirty(struct vt_device *vd, int x, int y) { @@ -828,17 +829,33 @@ vt_mark_mouse_position_as_dirty(struct vt_device *vd, int x, int y) vw = vd->vd_curwindow; vf = vw->vw_font; - area.tr_begin.tp_col = (x - vw->vw_offset.tp_col) / vf->vf_width; - area.tr_begin.tp_row = (y - vw->vw_offset.tp_row) / vf->vf_height; - area.tr_end.tp_col = - ((x + vd->vd_mcursor->width - vw->vw_offset.tp_col) / - vf->vf_width) + 1; - area.tr_end.tp_row = - ((y + vd->vd_mcursor->height - vw->vw_offset.tp_row) / - vf->vf_height) + 1; + if (vf != NULL) { + area.tr_begin.tp_col = (x - vw->vw_offset.tp_col) / + vf->vf_width; + area.tr_begin.tp_row = (y - vw->vw_offset.tp_row) / + vf->vf_height; + area.tr_end.tp_col = + ((x + vd->vd_mcursor->width - vw->vw_offset.tp_col) / + vf->vf_width) + 1; + area.tr_end.tp_row = + ((y + vd->vd_mcursor->height - vw->vw_offset.tp_row) / + vf->vf_height) + 1; + } else { + /* + * No font loaded (ie. vt_vga operating in textmode). + * + * FIXME: This fake area needs to be revisited once the + * mouse cursor is supported in vt_vga's textmode. + */ + area.tr_begin.tp_col = x; + area.tr_begin.tp_row = y; + area.tr_end.tp_col = x + 2; + area.tr_end.tp_row = y + 2; + } vtbuf_dirty(&vw->vw_buf, &area); } +#endif static void vt_bitblt_char(struct vt_device *vd, struct vt_font *vf, term_char_t c, |