9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] winwatch
@ 2007-01-01  8:55 lucio
  2007-01-02 22:34 ` David Leimbach
  0 siblings, 1 reply; 3+ messages in thread
From: lucio @ 2007-01-01  8:55 UTC (permalink / raw)
  To: 9fans

I replaced the code in click() with the following to add a half-baked
facility to hide a window with winwatch.  It uses the B3-B1 chord, but
somehow loses the ability to pick a window with B3 when the winwatch
window is not active.

void
click(Mouse m)
{
	int fd, w, b = m.buttons;
	Point xy = m.xy;
	char buf[128];

	do
		m = emouse();
	while(m.buttons == b);

	while (b) {
		for(w = 0; w < nwin; w++)
			if(ptinrect(xy, win[w].r))
				break;
		if(w < nwin) {
			sprint(buf, "/dev/wsys/%d/wctl", win[w].n);
			switch (b & 7) {
				case 1:
					break;
				case 2:
				case 3:
					break;
				case 4:
				case 6:
				case 7:
					if((fd = open(buf, OWRITE)) < 0)
						return;
					write(fd, "unhide\n", 7);
					write(fd, "top\n", 4);
					write(fd, "current\n", 8);
					close(fd);
					break;
				case 5:
					if((fd = open(buf, OWRITE)) < 0)
						return;
					write(fd, "top\n", 4);
					write(fd, "hide\n", 7);
					close(fd);
					break;
			}
		}
		b = m.buttons;
		xy = m.xy;
		do {
			m = emouse();
		} while (m.buttons);
	}
}

I am a little disappointed as to how complicated it is to implement
mouse functionality.  It seems a lot easier to expect the interactive
human to recover from unexpected conditions rather than try to design
the interaction so no condition is unexpected.  This is not a
criticism of Plan 9, far from it.  It is the realisation that by
putting a computer on every desk we (computer programmer, glorified or
otherwise) have turned computers from convenient slaves to eliminate
tedium to instruments requiring constant human attention.

++L



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-01-03  4:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-01  8:55 [9fans] winwatch lucio
2007-01-02 22:34 ` David Leimbach
2007-01-03  4:02   ` lucio

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).