diff options
author | Uwe Stuehler <uwe@cvs.openbsd.org> | 2005-04-24 23:43:16 +0000 |
---|---|---|
committer | Uwe Stuehler <uwe@cvs.openbsd.org> | 2005-04-24 23:43:16 +0000 |
commit | a839641559f30cebd3e47b70e80e0b362d215f3c (patch) | |
tree | 75451ac4bc1ff460a2654ee8fccfc6b600761f5e /usr.sbin/ztsscale | |
parent | 20c5431847c7d908b20cd88f164e00bc7278e7e7 (diff) |
use the last position of the pen before it was lifted up
Diffstat (limited to 'usr.sbin/ztsscale')
-rw-r--r-- | usr.sbin/ztsscale/ztsscale.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/usr.sbin/ztsscale/ztsscale.c b/usr.sbin/ztsscale/ztsscale.c index 02336a7bee7..fb8627b138e 100644 --- a/usr.sbin/ztsscale/ztsscale.c +++ b/usr.sbin/ztsscale/ztsscale.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ztsscale.c,v 1.3 2005/04/24 23:02:40 uwe Exp $ */ +/* $OpenBSD: ztsscale.c,v 1.4 2005/04/24 23:43:15 uwe Exp $ */ /* * Copyright (c) 2005 Matthieu Herrb @@ -75,8 +75,7 @@ wait_event(int mfd, int *x, int *y) struct wscons_event evbuf; down = 0; - *x = *y = -1; - while (!down || *x == -1 || *y == -1 ) { + while (!down) { len = read(mfd, &evbuf, sizeof(evbuf)); if (len != 16) break; @@ -84,15 +83,11 @@ wait_event(int mfd, int *x, int *y) case WSCONS_EVENT_MOUSE_DOWN: down = 1; break; - case WSCONS_EVENT_MOUSE_ABSOLUTE_X: - *x = evbuf.value; - break; - case WSCONS_EVENT_MOUSE_ABSOLUTE_Y: - *y = evbuf.value; - break; } } - while (down) { + + *x = *y = -1; + while (down || *x == -1 || *y == -1) { len = read(mfd, &evbuf, sizeof(evbuf)); if (len != 16) break; @@ -100,6 +95,14 @@ wait_event(int mfd, int *x, int *y) case WSCONS_EVENT_MOUSE_UP: down = 0; break; + case WSCONS_EVENT_MOUSE_ABSOLUTE_X: + if (down) + *x = evbuf.value; + break; + case WSCONS_EVENT_MOUSE_ABSOLUTE_Y: + if (down) + *y = evbuf.value; + break; } } } @@ -136,8 +139,7 @@ void sighandler(int sig) { restore_screen(); - close(fd); - _exit(2); + _exit(128 + sig); } int |