svn commit: r270342 - head/sys/dev/vt

Jean-Sebastien Pedron dumbbell at FreeBSD.org
Fri Aug 22 17:09:33 UTC 2014


Author: dumbbell
Date: Fri Aug 22 17:09:31 2014
New Revision: 270342
URL: http://svnweb.freebsd.org/changeset/base/270342

Log:
  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

Modified:
  head/sys/dev/vt/vt.h
  head/sys/dev/vt/vt_buf.c
  head/sys/dev/vt/vt_core.c

Modified: head/sys/dev/vt/vt.h
==============================================================================
--- head/sys/dev/vt/vt.h	Fri Aug 22 17:05:41 2014	(r270341)
+++ head/sys/dev/vt/vt.h	Fri Aug 22 17:09:31 2014	(r270342)
@@ -203,12 +203,12 @@ void vtbuf_grow(struct vt_buf *, const t
 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);

Modified: head/sys/dev/vt/vt_buf.c
==============================================================================
--- head/sys/dev/vt/vt_buf.c	Fri Aug 22 17:05:41 2014	(r270341)
+++ head/sys/dev/vt/vt_buf.c	Fri Aug 22 17:09:31 2014	(r270342)
@@ -246,7 +246,7 @@ vtbuf_dirty_locked(struct vt_buf *vb, co
 	    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,
 }
 
 #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)
 {

Modified: head/sys/dev/vt/vt_core.c
==============================================================================
--- head/sys/dev/vt/vt_core.c	Fri Aug 22 17:05:41 2014	(r270341)
+++ head/sys/dev/vt/vt_core.c	Fri Aug 22 17:09:31 2014	(r270342)
@@ -819,6 +819,28 @@ vt_determine_colors(term_char_t c, int c
 }
 
 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
 


More information about the svn-src-all mailing list