shithub: riscv

Download patch

ref: 0dc9c8d0199db2746f2ca651911e8fa60e90e02f
parent: 7de7414e885c3fa3c52200c49528e1e8da5adcc9
author: Ori Bernstein <ori@eigenstate.org>
date: Wed May 6 09:38:39 EDT 2020

Reset click count on mouse motion.

--- a/sys/src/cmd/acme/text.c
+++ b/sys/src/cmd/acme/text.c
@@ -868,7 +868,8 @@
 
 static	Text	*clicktext;
 static	uint	clickmsec;
-static int clickcount;
+static	int	clickcount;
+static	Point	clickpt;
 static	Text	*selecttext;
 static	uint	selectq;
 
@@ -927,9 +928,12 @@
 	b = mouse->buttons;
 	q0 = t->q0;
 	q1 = t->q1;
+	dx = abs(clickpt.x - w->mc.xy.x);
+	dy = abs(clickpt.y - w->mc.xy.y);
+	clickpt = w->mc.xy;
 	selectq = t->org+frcharofpt(t, mouse->xy);
 	clickcount++;
-	if(mouse->msec-clickmsec >= 500 || selecttext != t || clickcount > 3)
+	if(mouse->msec-clickmsec >= 500 || selecttext != t || clickcount > 3 || dx > 3 || dy > 3)
 		clickcount = 0;
 	if(clickcount >= 1 && selecttext==t && mouse->msec-clickmsec < 500){
 		textstretchsel(t, selectq, &q0, &q1, clickcount);
--- a/sys/src/cmd/rio/wind.c
+++ b/sys/src/cmd/rio/wind.c
@@ -962,6 +962,7 @@
 
 static Window	*clickwin;
 static uint	clickmsec;
+static Point	clickpt;
 static uint	clickcount;
 static Window	*selectwin;
 static uint	selectq;
@@ -1018,9 +1019,12 @@
 	b = w->mc.buttons;
 	q0 = w->q0;
 	q1 = w->q1;
+	dx = abs(clickpt.x - w->mc.xy.x);
+	dy = abs(clickpt.y - w->mc.xy.y);
+	clickpt = w->mc.xy;
 	selectq = w->org+frcharofpt(w, w->mc.xy);
 	clickcount++;
-	if(w->mc.msec-clickmsec >= 500 || clickwin != w || clickcount > 3)
+	if(w->mc.msec-clickmsec >= 500 || clickwin != w || clickcount > 3 || dx > 3 || dy > 3)
 		clickcount = 0;
 	if(clickwin == w && clickcount >= 1 && w->mc.msec-clickmsec < 500){
 		mode = (clickcount > 2) ? 2 : clickcount;