summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordumbbell <dumbbell@FreeBSD.org>2014-08-22 17:09:31 +0000
committerdumbbell <dumbbell@FreeBSD.org>2014-08-22 17:09:31 +0000
commite0854dd7f7473dd82eb07fd0779dbc6971b910fc (patch)
treedd943f2acce4ad2f36864420ac5936b782a3b460
parentb2469249b796b79cd1b9f0121b18c9bc7ca138fe (diff)
downloadFreeBSD-src-e0854dd7f7473dd82eb07fd0779dbc6971b910fc.zip
FreeBSD-src-e0854dd7f7473dd82eb07fd0779dbc6971b910fc.tar.gz
vt(4): Use the actual size of the mouse when marking its position as dirty
This fixes a bug where part of the cursor was not erased. MFC after: 1 week
-rw-r--r--sys/dev/vt/vt.h2
-rw-r--r--sys/dev/vt/vt_buf.c14
-rw-r--r--sys/dev/vt/vt_core.c53
3 files changed, 30 insertions, 39 deletions
diff --git a/sys/dev/vt/vt.h b/sys/dev/vt/vt.h
index abe48d3..0f1f0b0 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 e6efcd2..80fcd48 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 494bc76..7d98b82 100644
--- a/sys/dev/vt/vt_core.c
+++ b/sys/dev/vt/vt_core.c
@@ -819,6 +819,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
OpenPOWER on IntegriCloud