blob: dae0a6bcb29364b4d5ac499a14f5d57e78dc220d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#include <u.h>
#include <libc.h>
#include <draw.h>
#include <thread.h>
#include <cursor.h>
#include <mouse.h>
#include <keyboard.h>
#include <frame.h>
#include <fcall.h>
#include <plumb.h>
#include "dat.h"
static Point newmouse;
static Point oldmouse;
/* call moveto, but record old and new mouse positions */
void
recmoveto(Mousectl *mc, Point pt){
static vlong prevtime = 0;
vlong curtime = nsec();
if(curtime-prevtime>500000000){ /* 500ms */
newmouse = pt;
oldmouse = mouse->xy;
}
prevtime = curtime;
moveto(mc, pt);
}
void
undomoveto(Mousectl *mc){
Point tmp;
moveto(mc, oldmouse);
tmp = newmouse;
newmouse = oldmouse;
oldmouse = tmp;
}
|