diff options
author | philip <philip@FreeBSD.org> | 2005-12-04 00:28:40 +0000 |
---|---|---|
committer | philip <philip@FreeBSD.org> | 2005-12-04 00:28:40 +0000 |
commit | 7b7fd248389b497235a0e9dcef2aff317880a15b (patch) | |
tree | 04cdff7aec33055befaecf9e171e0b181bca0ea4 /usr.sbin/moused/moused.c | |
parent | 63d1fc762367223d38182342a0053ef4fcc269dc (diff) | |
download | FreeBSD-src-7b7fd248389b497235a0e9dcef2aff317880a15b.zip FreeBSD-src-7b7fd248389b497235a0e9dcef2aff317880a15b.tar.gz |
Add "yet another" moused(8) hack: suspend handling mouse events when SIGUSR1
is caught. Can be assigned to a window manager shortcut to prevent accidents
with touchpads.
PR: bin/89357
Submitted by: Nick Hibma <nick -at- van-laarhoven.org>
MFC after: 1 week
Diffstat (limited to 'usr.sbin/moused/moused.c')
-rw-r--r-- | usr.sbin/moused/moused.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/usr.sbin/moused/moused.c b/usr.sbin/moused/moused.c index 0ad46bd1..0ab9939 100644 --- a/usr.sbin/moused/moused.c +++ b/usr.sbin/moused/moused.c @@ -159,6 +159,7 @@ typedef struct { int debug = 0; int nodaemon = FALSE; int background = FALSE; +int paused = FALSE; int identify = ID_NONE; int extioctl = FALSE; char *pidfile = "/var/run/moused.pid"; @@ -496,6 +497,7 @@ static struct drift_xy drift_previous={0,0}; /* steps in previous drift_time */ static void moused(void); static void hup(int sig); static void cleanup(int sig); +static void pause_mouse(int sig); static void usage(void); static void log_or_warn(int log_pri, int errnum, const char *fmt, ...) __printflike(3, 4); @@ -833,6 +835,7 @@ main(int argc, char *argv[]) signal(SIGINT , cleanup); signal(SIGQUIT, cleanup); signal(SIGTERM, cleanup); + signal(SIGUSR1, pause_mouse); for (i = 0; i < retry; ++i) { if (i > 0) sleep(2); @@ -1195,7 +1198,8 @@ moused(void) mouse.u.data.y = action2.dy * rodent.accely; mouse.u.data.z = action2.dz; if (debug < 2) - ioctl(rodent.cfd, CONS_MOUSECTL, &mouse); + if (!paused) + ioctl(rodent.cfd, CONS_MOUSECTL, &mouse); } } else { mouse.operation = MOUSE_ACTION; @@ -1204,7 +1208,8 @@ moused(void) mouse.u.data.y = action2.dy * rodent.accely; mouse.u.data.z = action2.dz; if (debug < 2) - ioctl(rodent.cfd, CONS_MOUSECTL, &mouse); + if (!paused) + ioctl(rodent.cfd, CONS_MOUSECTL, &mouse); } /* @@ -1226,7 +1231,8 @@ moused(void) mouse.u.data.buttons = action2.button; mouse.u.data.x = mouse.u.data.y = mouse.u.data.z = 0; if (debug < 2) - ioctl(rodent.cfd, CONS_MOUSECTL, &mouse); + if (!paused) + ioctl(rodent.cfd, CONS_MOUSECTL, &mouse); } } } @@ -1248,6 +1254,12 @@ cleanup(int sig) exit(0); } +static void +pause_mouse(int sig) +{ + paused = !paused; +} + /** ** usage ** @@ -2536,7 +2548,8 @@ r_click(mousestatus_t *act) mouse.operation = MOUSE_BUTTON_EVENT; mouse.u.event.id = button; if (debug < 2) - ioctl(rodent.cfd, CONS_MOUSECTL, &mouse); + if (!paused) + ioctl(rodent.cfd, CONS_MOUSECTL, &mouse); debug("button %d count %d", i + 1, mouse.u.event.value); } button <<= 1; |