about summary refs log blame commit diff stats
path: root/p9c/draw/draw.c
blob: 696ce302b2f1686f91b98f355e935ac569ef3b80 (plain) (tree)



































                                                                            
#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);
		}
	}
}