Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 31 Jan 2008 13:54:06 GMT
From:      Aragon Gouveia <aragon@phat.za.net>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   misc/120186: moused improvement to virtual scrolling
Message-ID:  <200801311354.m0VDs6PS068869@www.freebsd.org>
Resent-Message-ID: <200801311400.m0VE07hi079015@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         120186
>Category:       misc
>Synopsis:       moused improvement to virtual scrolling
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jan 31 14:00:07 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator:     Aragon Gouveia
>Release:        FreeBSD 7.0-RC1
>Organization:
>Environment:
FreeBSD geek.pcs.intranet 7.0-RC1 FreeBSD 7.0-RC1 #0: Wed Jan 16 17:07:28 SAST 2008     root@geek.pcs.intranet:/usr/obj/usr/src/sys/GEEK  i386
>Description:
I recently upgraded to FreeBSD 7 and have been thoroughly enjoying the new moused features like virtual scrolling and exponential acceleration.  One thing that has been annoying me with virtual scrolling though is that one needs to hold the mouse VERY steady for a middle click to register as a button click.

I've attached a patch which addresses this issue and also adds a new argument, -L.  With the current implementation the -U (scroll threshold) argument affects the speed of scrolling too.  My patch makes -U set only the scroll threshold, and -L controls the speed of scrolling.

I've tested it briefly on my workstation and middle clicking feels MUCH more responsive now - day and night difference for me.  I hope I haven't forgotten anything, but please test it and consider committing this as I feel it is essential.

Patch attached.


Thanks,
Aragon

>How-To-Repeat:

>Fix:


Patch attached with submission follows:

--- moused.c.orig	2008-01-31 14:29:36.000000000 +0200
+++ moused.c	2008-01-31 15:46:16.000000000 +0200
@@ -77,6 +77,7 @@
 #define DFLT_CLICKTHRESHOLD	 500	/* 0.5 second */
 #define DFLT_BUTTON2TIMEOUT	 100	/* 0.1 second */
 #define DFLT_SCROLLTHRESHOLD	   3	/* 3 pixels */
+#define DFLT_SCROLLSPEED	   2	/* 2 pixels */
 
 /* Abort 3-button emulation delay after this many movement events. */
 #define BUTTON2_MAXMOVE	3
@@ -401,6 +402,7 @@
     float remainx;		/* Remainder on X and Y axis, respectively... */
     float remainy;		/*    ... to compensate for rounding errors. */
     int scrollthreshold;	/* Movement distance before virtual scrolling */
+    int scrollspeed;		/* Movement distance to rate of scrolling */
 } rodent = {
     .flags = 0,
     .portname = NULL,
@@ -424,6 +426,7 @@
     .remainx = 0.0,
     .remainy = 0.0,
     .scrollthreshold = DFLT_SCROLLTHRESHOLD,
+    .scrollspeed = DFLT_SCROLLSPEED,
 };
 
 /* button status */
@@ -554,7 +557,7 @@
     for (i = 0; i < MOUSE_MAXBUTTON; ++i)
 	mstate[i] = &bstate[i];
 
-    while ((c = getopt(argc, argv, "3A:C:DE:F:HI:PRS:T:VU:a:cdfhi:l:m:p:r:st:w:z:")) != -1)
+    while ((c = getopt(argc, argv, "3A:C:DE:F:HI:L:PRS:T:VU:a:cdfhi:l:m:p:r:st:w:z:")) != -1)
 	switch(c) {
 
 	case '3':
@@ -740,6 +743,14 @@
 	    pidfile = optarg;
 	    break;
 
+	case 'L':
+	    rodent.scrollspeed = atoi(optarg);
+	    if (rodent.scrollspeed < 0) {
+		warnx("invalid argument `%s'", optarg);
+		usage();
+	    }
+	    break;
+
 	case 'P':
 	    rodent.flags |= NoPnP;
 	    break;
@@ -1100,6 +1111,7 @@
 		if (action0.button == MOUSE_BUTTON2DOWN) {
 		    if (scroll_state == SCROLL_NOTSCROLLING) {
 			scroll_state = SCROLL_PREPARE;
+			scroll_movement = hscroll_movement = 0;
 			debug("PREPARING TO SCROLL");
 		    }
 		    debug("[BUTTON2] flags:%08x buttons:%08x obuttons:%08x",
@@ -1161,21 +1173,38 @@
 		 * the stick/trackpoint/nipple, scroll!
 		 */
 		if (scroll_state == SCROLL_PREPARE) {
-		    /* Ok, Set we're really scrolling now.... */
-		    if (action2.dy || action2.dx)
-			scroll_state = SCROLL_SCROLLING;
+			/* Middle button down, waiting for movement threshold */
+			if (action2.dy || action2.dx) {
+				if (rodent.flags & VirtualScroll) {
+					scroll_movement += action2.dy;
+					if (scroll_movement < -rodent.scrollthreshold) {
+						scroll_state = SCROLL_SCROLLING;
+					} else if (scroll_movement > rodent.scrollthreshold) {
+						scroll_state = SCROLL_SCROLLING;
+					}
+				}
+				if (rodent.flags & HVirtualScroll) {
+					hscroll_movement += action2.dx;
+					if (hscroll_movement < -rodent.scrollthreshold) {
+						scroll_state = SCROLL_SCROLLING;
+					} else if (hscroll_movement > rodent.scrollthreshold) {
+						scroll_state = SCROLL_SCROLLING;
+					}
+				}
+				if (scroll_state == SCROLL_SCROLLING) scroll_movement = hscroll_movement = 0;
+			}
 		}
 		if (scroll_state == SCROLL_SCROLLING) {
 			 if (rodent.flags & VirtualScroll) {
 				 scroll_movement += action2.dy;
 				 debug("SCROLL: %d", scroll_movement);
 
-			    if (scroll_movement < -rodent.scrollthreshold) { 
+			    if (scroll_movement < -rodent.scrollspeed) { 
 				/* Scroll down */
 				action2.dz = -1;
 				scroll_movement = 0;
 			    }
-			    else if (scroll_movement > rodent.scrollthreshold) { 
+			    else if (scroll_movement > rodent.scrollspeed) { 
 				/* Scroll up */
 				action2.dz = 1;
 				scroll_movement = 0;
@@ -1185,11 +1214,11 @@
 				 hscroll_movement += action2.dx;
 				 debug("HORIZONTAL SCROLL: %d", hscroll_movement);
 
-				 if (hscroll_movement < -rodent.scrollthreshold) {
+				 if (hscroll_movement < -rodent.scrollspeed) {
 					 action2.dz = -2;
 					 hscroll_movement = 0;
 				 }
-				 else if (hscroll_movement > rodent.scrollthreshold) {
+				 else if (hscroll_movement > rodent.scrollspeed) {
 					 action2.dz = 2;
 					 hscroll_movement = 0;
 				 }


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200801311354.m0VDs6PS068869>