diff options
author | John Ankarström <john@ankarstrom.se> | 2021-01-28 21:33:30 +0000 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2021-01-28 21:33:30 +0000 |
commit | 51b5b02f52cc6f314029f3f2fe97afdc26ba0f25 (patch) | |
tree | 711d1efadeb78ad9b2d9f7b629350358838bc626 /patch/acme-moveto-undo/moveto.c | |
parent | f3fd330cddade1c66d0f101d5cc6f657c4cd1bb6 (diff) | |
download | plan9-51b5b02f52cc6f314029f3f2fe97afdc26ba0f25.tar.gz |
Add various patches
Diffstat (limited to 'patch/acme-moveto-undo/moveto.c')
-rw-r--r-- | patch/acme-moveto-undo/moveto.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/patch/acme-moveto-undo/moveto.c b/patch/acme-moveto-undo/moveto.c new file mode 100644 index 0000000..dae0a6b --- /dev/null +++ b/patch/acme-moveto-undo/moveto.c @@ -0,0 +1,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; +} + |