diff options
author | aiju <aiju@phicode.de> | 2011-05-09 08:48:14 +0000 |
---|---|---|
committer | aiju <aiju@phicode.de> | 2011-05-09 08:48:14 +0000 |
commit | ed3a999828fa841c803993ed4ad8ab545b876aeb (patch) | |
tree | 5e0e255729c84dbcc704608b6cb58277dc5a1429 /sys/src | |
parent | 22ec6165bc7ffe68c82e1b14d6d77045c8c3605b (diff) |
added absolute movement for mousein
Diffstat (limited to 'sys/src')
-rw-r--r-- | sys/src/9/pc/screen.h | 1 | ||||
-rw-r--r-- | sys/src/9/port/devmouse.c | 48 |
2 files changed, 46 insertions, 3 deletions
diff --git a/sys/src/9/pc/screen.h b/sys/src/9/pc/screen.h index a9d1b66a4..87771f60b 100644 --- a/sys/src/9/pc/screen.h +++ b/sys/src/9/pc/screen.h @@ -7,6 +7,7 @@ struct Cursorinfo { /* devmouse.c */ extern void mousetrack(int, int, int, int); +extern void absmousetrack(int, int, int, int); extern Point mousexy(void); extern void mouseaccelerate(int); diff --git a/sys/src/9/port/devmouse.c b/sys/src/9/port/devmouse.c index 5b620720c..24c66ec45 100644 --- a/sys/src/9/port/devmouse.c +++ b/sys/src/9/port/devmouse.c @@ -454,16 +454,19 @@ mousewrite(Chan *c, void *va, long n, vlong) buf[n] = 0; p = 0; pt.x = strtol(buf+1, &p, 0); - if(p == 0) + if(*p == 0) error(Eshort); pt.y = strtol(p, &p, 0); - if(p == 0) + if(*p == 0) error(Eshort); b = strtol(p, &p, 0); msec = strtol(p, &p, 0); if(msec == 0) msec = TK2MS(MACHP(0)->ticks); - mousetrack(pt.x, pt.y, b, msec); + if(buf[0] == 'A') + absmousetrack(pt.x, pt.y, b, msec); + else + mousetrack(pt.x, pt.y, b, msec); return n; case Qmouse: @@ -620,6 +623,45 @@ mousetrack(int dx, int dy, int b, int msec) drawactive(1); } +void +absmousetrack(int x, int y, int b, int msec) +{ + int lastb; + + if(gscreen==nil) + return; + + if(x < gscreen->clipr.min.x) + x = gscreen->clipr.min.x; + if(x >= gscreen->clipr.max.x) + x = gscreen->clipr.max.x; + if(y < gscreen->clipr.min.y) + y = gscreen->clipr.min.y; + if(y >= gscreen->clipr.max.y) + y = gscreen->clipr.max.y; + + lastb = mouse.buttons; + mouse.xy = Pt(x, y); + mouse.buttons = b|kbdbuttons; + mouse.redraw = 1; + mouse.counter++; + mouse.msec = msec; + + /* + * if the queue fills, we discard the entire queue and don't + * queue any more events until a reader polls the mouse. + */ + if(!mouse.qfull && lastb != b) { /* add to ring */ + mouse.queue[mouse.wi] = mouse.Mousestate; + if(++mouse.wi == nelem(mouse.queue)) + mouse.wi = 0; + if(mouse.wi == mouse.ri) + mouse.qfull = 1; + } + wakeup(&mouse.r); + drawactive(1); +} + /* * microsoft 3 button, 7 bit bytes * |