mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-12 11:10:07 +00:00
devdraw: correct mouse event buffering on OS X
This commit is contained in:
parent
c752966bcb
commit
1f74e1b758
1 changed files with 22 additions and 15 deletions
|
@ -45,6 +45,7 @@ struct Kbdbuf
|
|||
struct Mousebuf
|
||||
{
|
||||
Mouse m[32];
|
||||
Mouse last;
|
||||
int ri;
|
||||
int wi;
|
||||
int stall;
|
||||
|
@ -201,7 +202,6 @@ runmsg(Wsysmsg *m)
|
|||
mousetags.wi = 0;
|
||||
if(mousetags.wi == mousetags.ri)
|
||||
sysfatal("too many queued mouse reads");
|
||||
/* fprint(2, "mouse unstall\n"); */
|
||||
mouse.stall = 0;
|
||||
matchmouse();
|
||||
zunlock();
|
||||
|
@ -379,21 +379,28 @@ mousetrack(int x, int y, int b, int ms)
|
|||
y = mouserect.max.y;
|
||||
|
||||
zlock();
|
||||
m = &mouse.m[mouse.wi];
|
||||
m->xy.x = x;
|
||||
m->xy.y = y;
|
||||
m->buttons = b;
|
||||
m->msec = ms;
|
||||
mouse.wi++;
|
||||
if(mouse.wi == nelem(mouse.m))
|
||||
mouse.wi = 0;
|
||||
if(mouse.wi == mouse.ri){
|
||||
mouse.stall = 1;
|
||||
mouse.ri = 0;
|
||||
mouse.wi = 1;
|
||||
mouse.m[0] = *m;
|
||||
// If reader has stopped reading, don't bother.
|
||||
// If reader is completely caught up, definitely queue.
|
||||
// Otherwise, queue only button change events.
|
||||
if(!mouse.stall)
|
||||
if(mouse.wi == mouse.ri || mouse.last.buttons != b){
|
||||
m = &mouse.last;
|
||||
m->xy.x = x;
|
||||
m->xy.y = y;
|
||||
m->buttons = b;
|
||||
m->msec = ms;
|
||||
|
||||
mouse.m[mouse.wi] = *m;
|
||||
if(++mouse.wi == nelem(mouse.m))
|
||||
mouse.wi = 0;
|
||||
if(mouse.wi == mouse.ri){
|
||||
mouse.stall = 1;
|
||||
mouse.ri = 0;
|
||||
mouse.wi = 1;
|
||||
mouse.m[0] = *m;
|
||||
}
|
||||
matchmouse();
|
||||
}
|
||||
matchmouse();
|
||||
zunlock();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue