devmouse: differential handling of /dev/mousein buttons
This commit is contained in:
parent
ad1111cb3e
commit
6c6bd66ed1
1 changed files with 17 additions and 0 deletions
|
@ -71,6 +71,7 @@ Mouseinfo mouse;
|
|||
Cursorinfo cursor;
|
||||
int mouseshifted;
|
||||
Cursor curs;
|
||||
int mouseinbuttons;
|
||||
|
||||
void Cursortocursor(Cursor*);
|
||||
int mousechanged(void*);
|
||||
|
@ -192,6 +193,9 @@ mouseopen(Chan *c, int omode)
|
|||
case Qmousein:
|
||||
if(!iseve())
|
||||
error(Eperm);
|
||||
c->aux = malloc(sizeof(Mousestate));
|
||||
if(c->aux == nil)
|
||||
error(Enomem);
|
||||
break;
|
||||
default:
|
||||
incref(&mouse);
|
||||
|
@ -220,6 +224,9 @@ mouseclose(Chan *c)
|
|||
mouse.open = 0;
|
||||
else if(c->qid.path == Qmousein){
|
||||
unlock(&mouse);
|
||||
mouseinbuttons &= ~((Mousestate*)c->aux)->buttons;
|
||||
free(c->aux); /* Mousestate */
|
||||
c->aux = nil;
|
||||
return;
|
||||
}
|
||||
if(--mouse.ref != 0){
|
||||
|
@ -368,6 +375,7 @@ mousewrite(Chan *c, void *va, long n, vlong)
|
|||
Cmdtab *ct;
|
||||
char buf[64];
|
||||
int b, msec;
|
||||
Mousestate *m;
|
||||
|
||||
p = va;
|
||||
switch((ulong)c->qid.path){
|
||||
|
@ -448,6 +456,13 @@ mousewrite(Chan *c, void *va, long n, vlong)
|
|||
msec = strtol(p, &p, 0);
|
||||
if(msec == 0)
|
||||
msec = TK2MS(MACHP(0)->ticks);
|
||||
m = (Mousestate*)c->aux;
|
||||
m->xy = pt;
|
||||
m->msec = msec;
|
||||
b ^= m->buttons;
|
||||
m->buttons ^= b;
|
||||
mouseinbuttons = (m->buttons & b) | (mouseinbuttons & ~b);
|
||||
b = mouse.buttons & ~b;
|
||||
if(buf[0] == 'A')
|
||||
absmousetrack(pt.x, pt.y, b, msec);
|
||||
else
|
||||
|
@ -598,6 +613,8 @@ absmousetrack(int x, int y, int b, int msec)
|
|||
if(y >= gscreen->clipr.max.y)
|
||||
y = gscreen->clipr.max.y;
|
||||
|
||||
b |= mouseinbuttons;
|
||||
|
||||
lastb = mouse.buttons;
|
||||
mouse.xy = Pt(x, y);
|
||||
mouse.buttons = b;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue