about summary refs log tree commit diff stats
path: root/p9c/mouse.c
blob: 214526ab5f8aefd8010536d770c8ff4713a9bd1c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#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[])
{
	// USED(argc, 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);
		}
	}
}