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

Jean-Sebastien Pedron dumbbell at FreeBSD.org
Thu Aug 21 13:04:35 UTC 2014


Author: dumbbell
Date: Thu Aug 21 13:04:34 2014
New Revision: 270269
URL: http://svnweb.freebsd.org/changeset/base/270269

Log:
  vt(4): Handle global and per-window mouse cursor toggle in one place
  
  Before the global flag was set/unset using the CONS_MOUSECTL ioctl, and
  the per-window flag through the MOUSE_SETLEVEL or MOUSE_SETMODE ioctls.
  
  Also, if the cursor is already enabled/disabled, return immediatly. This
  avoids to reset the cursor's position to the center of the screen.
  
  This matches syscons' behavior.
  
  While here, remove a trailing space and a redundant variable
  declaration.

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

Modified: head/sys/dev/vt/vt_core.c
==============================================================================
--- head/sys/dev/vt/vt_core.c	Thu Aug 21 12:50:11 2014	(r270268)
+++ head/sys/dev/vt/vt_core.c	Thu Aug 21 13:04:34 2014	(r270269)
@@ -1703,7 +1703,7 @@ skip_thunk:
 		/* XXX: other fields! */
 		return (0);
 	}
-	case CONS_GETVERS: 
+	case CONS_GETVERS:
 		*(int *)data = 0x200;
 		return (0);
 	case CONS_MODEINFO:
@@ -1713,20 +1713,28 @@ skip_thunk:
 		mouse_info_t *mouse = (mouse_info_t*)data;
 
 		/*
-		 * This has no effect on vt(4).  We don't draw any mouse
-		 * cursor.  Just ignore MOUSE_HIDE and MOUSE_SHOW to
-		 * prevent excessive errors.  All the other commands
+		 * All the commands except MOUSE_SHOW nd MOUSE_HIDE
 		 * should not be applied to individual TTYs, but only to
 		 * consolectl.
 		 */
 		switch (mouse->operation) {
 		case MOUSE_HIDE:
-			vd->vd_flags &= ~VDF_MOUSECURSOR;
+			if (vd->vd_flags & VDF_MOUSECURSOR) {
+				vd->vd_flags &= ~VDF_MOUSECURSOR;
+#ifndef SC_NO_CUTPASTE
+				vt_mouse_state(VT_MOUSE_HIDE);
+#endif
+			}
 			return (0);
 		case MOUSE_SHOW:
-			vd->vd_mx = vd->vd_width / 2;
-			vd->vd_my = vd->vd_height / 2;
-			vd->vd_flags |= VDF_MOUSECURSOR;
+			if (!(vd->vd_flags & VDF_MOUSECURSOR)) {
+				vd->vd_flags |= VDF_MOUSECURSOR;
+				vd->vd_mx = vd->vd_width / 2;
+				vd->vd_my = vd->vd_height / 2;
+#ifndef SC_NO_CUTPASTE
+				vt_mouse_state(VT_MOUSE_SHOW);
+#endif
+			}
 			return (0);
 		default:
 			return (EINVAL);
@@ -1749,7 +1757,6 @@ skip_thunk:
 	}
 	case GIO_SCRNMAP: {
 		scrmap_t *sm = (scrmap_t *)data;
-		int i;
 
 		/* We don't have screen maps, so return a handcrafted one. */
 		for (i = 0; i < 256; i++)

Modified: head/sys/dev/vt/vt_sysmouse.c
==============================================================================
--- head/sys/dev/vt/vt_sysmouse.c	Thu Aug 21 12:50:11 2014	(r270268)
+++ head/sys/dev/vt/vt_sysmouse.c	Thu Aug 21 13:04:34 2014	(r270269)
@@ -347,9 +347,6 @@ sysmouse_ioctl(struct cdev *dev, u_long 
 			return (EINVAL);
 
 		sysmouse_level = level;
-#ifndef SC_NO_CUTPASTE
-		vt_mouse_state((level == 0)?VT_MOUSE_SHOW:VT_MOUSE_HIDE);
-#endif
 		return (0);
 	}
 	case MOUSE_SETMODE: {
@@ -362,10 +359,6 @@ sysmouse_ioctl(struct cdev *dev, u_long 
 		case 0:
 		case 1:
 			sysmouse_level = mode->level;
-#ifndef SC_NO_CUTPASTE
-			vt_mouse_state((mode->level == 0)?VT_MOUSE_SHOW:
-			    VT_MOUSE_HIDE);
-#endif
 			break;
 		default:
 			return (EINVAL);


More information about the svn-src-all mailing list