static long pointerwrite(Chan* c, void* va, long n, vlong) { char *a = va; char buf[128]; int b, x, y; switch((ulong)c->qid.path){ case Qpointer: if(n > sizeof buf-1) n = sizeof buf -1; memmove(buf, va, n); buf[n] = 0; x = strtoul(buf+1, &a, 0); if(*a == 0) error(Eshort); y = strtoul(a, &a, 0); if(*a != 0) b = strtoul(a, 0, 0); else b = mouse.b; mousetrack(b, x, y, 0); break; default: error(Ebadusefd); } return n; }
boolean trackicon (Rect r, void (*displayiconcallback) (boolean)) { /* this is really more general than its name implies, but for now it covers the common calling mousetracking conventions use by all the windoid icons, and belongs here. 12/12/90 dmb: if mousetrack returns false, icon has already been displayed in off state, and shouldn't be redisplayed (in case callback uses simple inversion) */ setcursortype (cursorisarrow); /*get rid of funny appendage*/ (*displayiconcallback) (true); /*show icon in depressed state*/ if (!mousetrack (r, displayiconcallback)) /*if false, mouse didn't stay in rectangle*/ return (false); (*displayiconcallback) (false); /*show icon in un-depressed state*/ return (true); } /*trackicon*/
void sendbuttons(int b, int x, int y) { // fprint(2, "sendbuttons: b: %d; x: %d; y: %d\n", b, x, y); mousetrack(b, x, y, 0); }