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
|
struct Mousebuf
|
||||||
{
|
{
|
||||||
Mouse m[32];
|
Mouse m[32];
|
||||||
|
Mouse last;
|
||||||
int ri;
|
int ri;
|
||||||
int wi;
|
int wi;
|
||||||
int stall;
|
int stall;
|
||||||
|
@ -201,7 +202,6 @@ runmsg(Wsysmsg *m)
|
||||||
mousetags.wi = 0;
|
mousetags.wi = 0;
|
||||||
if(mousetags.wi == mousetags.ri)
|
if(mousetags.wi == mousetags.ri)
|
||||||
sysfatal("too many queued mouse reads");
|
sysfatal("too many queued mouse reads");
|
||||||
/* fprint(2, "mouse unstall\n"); */
|
|
||||||
mouse.stall = 0;
|
mouse.stall = 0;
|
||||||
matchmouse();
|
matchmouse();
|
||||||
zunlock();
|
zunlock();
|
||||||
|
@ -379,13 +379,19 @@ mousetrack(int x, int y, int b, int ms)
|
||||||
y = mouserect.max.y;
|
y = mouserect.max.y;
|
||||||
|
|
||||||
zlock();
|
zlock();
|
||||||
m = &mouse.m[mouse.wi];
|
// 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.x = x;
|
||||||
m->xy.y = y;
|
m->xy.y = y;
|
||||||
m->buttons = b;
|
m->buttons = b;
|
||||||
m->msec = ms;
|
m->msec = ms;
|
||||||
mouse.wi++;
|
|
||||||
if(mouse.wi == nelem(mouse.m))
|
mouse.m[mouse.wi] = *m;
|
||||||
|
if(++mouse.wi == nelem(mouse.m))
|
||||||
mouse.wi = 0;
|
mouse.wi = 0;
|
||||||
if(mouse.wi == mouse.ri){
|
if(mouse.wi == mouse.ri){
|
||||||
mouse.stall = 1;
|
mouse.stall = 1;
|
||||||
|
@ -394,6 +400,7 @@ mousetrack(int x, int y, int b, int ms)
|
||||||
mouse.m[0] = *m;
|
mouse.m[0] = *m;
|
||||||
}
|
}
|
||||||
matchmouse();
|
matchmouse();
|
||||||
|
}
|
||||||
zunlock();
|
zunlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue