9 moveto(Mousectl *mc, Point pt)
11 _displaymoveto(mc->display, pt);
16 closemouse(Mousectl *mc)
21 /* postnote(PNPROC, mc->pid, "kill"); */
23 do; while(nbrecv(mc->c, &mc->m) > 0);
25 chanfree(mc->resizec);
30 readmouse(Mousectl *mc)
33 flushimage(mc->display, 1);
34 if(recv(mc->c, &mc->m) < 0){
35 fprint(2, "readmouse: %r\n");
50 threadsetname("mouseproc");
51 memset(&m, 0, sizeof m);
55 if(_displayrdmouse(mc->display, &m, &resized) < 0) {
56 if(postnote(PNPROC, getpid(), "hangup") < 0)
57 fprint(2, "postnote: %r\n");
59 threadexitsall("mouse read error");
62 send(mc->resizec, &one);
65 * mc->m is updated after send so it doesn't have wrong value if we block during send.
66 * This means that programs should receive into mc->Mouse (see readmouse() above) if
67 * they want full synchrony.
74 initmouse(char *file, Image *i)
78 mc = mallocz(sizeof(Mousectl), 1);
80 mc->display = i->display;
81 mc->c = chancreate(sizeof(Mouse), 0);
82 chansetname(mc->c, "mousec");
83 mc->resizec = chancreate(sizeof(int), 2);
84 chansetname(mc->resizec, "resizec");
85 proccreate(_ioproc, mc, 32*1024);
90 setcursor(Mousectl *mc, Cursor *c)
92 _displaycursor(mc->display, c, nil);
96 setcursor2(Mousectl *mc, Cursor *c, Cursor2 *c2)
98 _displaycursor(mc->display, c, c2);