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

Ed Maste emaste at FreeBSD.org
Fri Apr 24 17:36:27 UTC 2015


Author: emaste
Date: Fri Apr 24 17:36:26 2015
New Revision: 281944
URL: https://svnweb.freebsd.org/changeset/base/281944

Log:
  vt(4): Simplify mouse area detection
  
  vt_is_cursor_in_area needs to return true if any part of the mouse
  cursor is visible in the rectangle area. Replace the existing test with
  a simpler version of a test for overlapping rectangles.
  
  Differential Revision:	https://reviews.freebsd.org/D2356
  Reviewed by:	ray
  Sponsored by:	The FreeBSD Foundation

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

Modified: head/sys/dev/vt/vt_core.c
==============================================================================
--- head/sys/dev/vt/vt_core.c	Fri Apr 24 17:05:18 2015	(r281943)
+++ head/sys/dev/vt/vt_core.c	Fri Apr 24 17:36:26 2015	(r281944)
@@ -1029,7 +1029,7 @@ vt_determine_colors(term_char_t c, int c
 int
 vt_is_cursor_in_area(const struct vt_device *vd, const term_rect_t *area)
 {
-	unsigned int mx, my, x1, y1, x2, y2;
+	unsigned int mx, my;
 
 	/*
 	 * We use the cursor position saved during the current refresh,
@@ -1038,18 +1038,12 @@ vt_is_cursor_in_area(const struct vt_dev
 	mx = vd->vd_mx_drawn + vd->vd_curwindow->vw_draw_area.tr_begin.tp_col;
 	my = vd->vd_my_drawn + vd->vd_curwindow->vw_draw_area.tr_begin.tp_row;
 
-	x1 = area->tr_begin.tp_col;
-	y1 = area->tr_begin.tp_row;
-	x2 = area->tr_end.tp_col;
-	y2 = area->tr_end.tp_row;
-
-	if (((mx >= x1 && x2 - 1 >= mx) ||
-	     (mx < x1 && mx + vd->vd_mcursor->width >= x1)) &&
-	    ((my >= y1 && y2 - 1 >= my) ||
-	     (my < y1 && my + vd->vd_mcursor->height >= y1)))
-		return (1);
-
-	return (0);
+	if (mx >= area->tr_end.tp_col ||
+	    mx + vd->vd_mcursor->width <= area->tr_begin.tp_col ||
+	    my >= area->tr_end.tp_row ||
+	    my + vd->vd_mcursor->height <= area->tr_begin.tp_row)
+		return (0);
+	return (1);
 }
 
 static void


More information about the svn-src-head mailing list