diff --git a/sys/dev/vt/vt.h b/sys/dev/vt/vt.h index abe48d3518a..0f1f0b0f6db 100644 --- a/sys/dev/vt/vt.h +++ b/sys/dev/vt/vt.h @@ -203,12 +203,12 @@ void vtbuf_grow(struct vt_buf *, const term_pos_t *, int); void vtbuf_putchar(struct vt_buf *, const term_pos_t *, term_char_t); void vtbuf_cursor_position(struct vt_buf *, const term_pos_t *); void vtbuf_scroll_mode(struct vt_buf *vb, int yes); +void vtbuf_dirty(struct vt_buf *vb, const term_rect_t *area); void vtbuf_undirty(struct vt_buf *, term_rect_t *, struct vt_bufmask *); void vtbuf_sethistory_size(struct vt_buf *, int); int vtbuf_iscursor(const struct vt_buf *vb, int row, int col); void vtbuf_cursor_visibility(struct vt_buf *, int); #ifndef SC_NO_CUTPASTE -void vtbuf_mouse_cursor_position(struct vt_buf *vb, int col, int row); int vtbuf_set_mark(struct vt_buf *vb, int type, int col, int row); int vtbuf_get_marked_len(struct vt_buf *vb); void vtbuf_extract_marked(struct vt_buf *vb, term_char_t *buf, int sz); diff --git a/sys/dev/vt/vt_buf.c b/sys/dev/vt/vt_buf.c index e6efcd2888f..80fcd485f07 100644 --- a/sys/dev/vt/vt_buf.c +++ b/sys/dev/vt/vt_buf.c @@ -246,7 +246,7 @@ vtbuf_dirty_locked(struct vt_buf *vb, const term_rect_t *area) vtbuf_dirty_axis(area->tr_begin.tp_col, area->tr_end.tp_col); } -static inline void +void vtbuf_dirty(struct vt_buf *vb, const term_rect_t *area) { @@ -558,18 +558,6 @@ vtbuf_cursor_position(struct vt_buf *vb, const term_pos_t *p) } #ifndef SC_NO_CUTPASTE -void -vtbuf_mouse_cursor_position(struct vt_buf *vb, int col, int row) -{ - term_rect_t area; - - area.tr_begin.tp_row = MAX(row - 1, 0); - area.tr_begin.tp_col = MAX(col - 1, 0); - area.tr_end.tp_row = MIN(row + 2, vb->vb_scr_size.tp_row); - area.tr_end.tp_col = MIN(col + 2, vb->vb_scr_size.tp_col); - vtbuf_dirty(vb, &area); -} - static void vtbuf_flush_mark(struct vt_buf *vb) { diff --git a/sys/dev/vt/vt_core.c b/sys/dev/vt/vt_core.c index 494bc76b2a3..7d98b82aa41 100644 --- a/sys/dev/vt/vt_core.c +++ b/sys/dev/vt/vt_core.c @@ -818,6 +818,28 @@ vt_determine_colors(term_char_t c, int cursor, } } +static void +vt_mark_mouse_position_as_dirty(struct vt_device *vd, int x, int y) +{ + term_rect_t area; + struct vt_window *vw; + struct vt_font *vf; + + 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; + + vtbuf_dirty(&vw->vw_buf, &area); +} + static void vt_bitblt_char(struct vt_device *vd, struct vt_font *vf, term_char_t c, int iscursor, unsigned int row, unsigned int col) @@ -884,23 +906,11 @@ vt_flush(struct vt_device *vd) /* * Mark last mouse position as dirty to erase. * - * FIXME: The font size could be different among - * all windows, so the column/row calculation - * below isn't correct for all windows. - * - * FIXME: The cursor can span more than one - * character cell. vtbuf_mouse_cursor_position - * marks surrounding cells as dirty. But due - * to font size possibly inconsistent across - * windows, this may not be sufficient. This - * causes part of the cursor to not be erased. - * * FIXME: The vt_buf lock is acquired twice in a * row. */ - vtbuf_mouse_cursor_position(&vw->vw_buf, - vd->vd_moldx / vf->vf_width, - vd->vd_moldy / vf->vf_height); + vt_mark_mouse_position_as_dirty(vd, + vd->vd_moldx, vd->vd_moldy); /* * Save point of last mouse cursor to erase it @@ -915,9 +925,8 @@ vt_flush(struct vt_device *vd) cursor_displayed = 1; /* Mark new mouse position as dirty. */ - vtbuf_mouse_cursor_position(&vw->vw_buf, - vd->vd_mx / vf->vf_width, - vd->vd_my / vf->vf_height); + vt_mark_mouse_position_as_dirty(vd, + vd->vd_mx, vd->vd_my); } } #endif @@ -1618,14 +1627,8 @@ vt_mouse_state(int show) break; } - /* - * Mark mouse position as dirty. - * - * FIXME: See comments in vt_flush(). - */ - vtbuf_mouse_cursor_position(&vw->vw_buf, - vd->vd_mx / vw->vw_font->vf_width, - vd->vd_my / vw->vw_font->vf_height); + /* Mark mouse position as dirty. */ + vt_mark_mouse_position_as_dirty(vd, vd->vd_mx, vd->vd_my); } #endif