summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2020-05-06 13:38:39 -0700
committerOri Bernstein <ori@eigenstate.org>2020-05-06 13:38:39 -0700
commit0dc9c8d0199db2746f2ca651911e8fa60e90e02f (patch)
tree058989d01fa16c74982b5026a394b1cf2bee435b /sys
parent7de7414e885c3fa3c52200c49528e1e8da5adcc9 (diff)
Reset click count on mouse motion.
Diffstat (limited to 'sys')
-rw-r--r--sys/src/cmd/acme/text.c8
-rw-r--r--sys/src/cmd/rio/wind.c6
2 files changed, 11 insertions, 3 deletions
diff --git a/sys/src/cmd/acme/text.c b/sys/src/cmd/acme/text.c
index 9611a2e4b..1821778c4 100644
--- a/sys/src/cmd/acme/text.c
+++ b/sys/src/cmd/acme/text.c
@@ -868,7 +868,8 @@ textcommit(Text *t, int tofile)
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 @@ textselect(Text *t)
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);
diff --git a/sys/src/cmd/rio/wind.c b/sys/src/cmd/rio/wind.c
index a9cfd248e..2aa3dd715 100644
--- a/sys/src/cmd/rio/wind.c
+++ b/sys/src/cmd/rio/wind.c
@@ -962,6 +962,7 @@ wdelete(Window *w, uint q0, uint q1)
static Window *clickwin;
static uint clickmsec;
+static Point clickpt;
static uint clickcount;
static Window *selectwin;
static uint selectq;
@@ -1018,9 +1019,12 @@ wselect(Window *w)
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;