#include <u.h>
#include <libc.h>
#include <draw.h>
#include <event.h>
void
eresized(int new)
{
if(new&& getwindow(display, Refnone) < 0)
sysfatal("can't reattach to window");
}
void
main(int argc, char* argv[])
{
Mouse m;
Point prevm;
initdraw(0, 0, "Example: Mouse");
eresized(0);
einit(Emouse);
/* Main loop */
for(;;) {
m = emouse();
if(m.buttons & 4)
break;
if(m.buttons & 1) {
line(screen,
prevm.x == -1 ? m.xy : prevm,
m.xy, Enddisc, Enddisc, 1, display->black, ZP);
prevm = m.xy;
} else {
prevm = Pt(-1, -1);
}
}
}