summaryrefslogtreecommitdiffstats
path: root/usr.sbin/moused
diff options
context:
space:
mode:
authorphilip <philip@FreeBSD.org>2005-12-04 00:28:40 +0000
committerphilip <philip@FreeBSD.org>2005-12-04 00:28:40 +0000
commit7b7fd248389b497235a0e9dcef2aff317880a15b (patch)
tree04cdff7aec33055befaecf9e171e0b181bca0ea4 /usr.sbin/moused
parent63d1fc762367223d38182342a0053ef4fcc269dc (diff)
downloadFreeBSD-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')
-rw-r--r--usr.sbin/moused/moused.823
-rw-r--r--usr.sbin/moused/moused.c21
2 files changed, 38 insertions, 6 deletions
diff --git a/usr.sbin/moused/moused.8 b/usr.sbin/moused/moused.8
index ed6ab56..38146da 100644
--- a/usr.sbin/moused/moused.8
+++ b/usr.sbin/moused/moused.8
@@ -89,10 +89,16 @@ data to the device so that the user program will see it.
.Pp
If the mouse daemon receives the signal
.Dv SIGHUP ,
-it will reopen the mouse port and reinitialize itself.
-Useful if
+it will reopen the mouse port and reinitialize itself. Useful if
the mouse is attached/detached while the system is suspended.
.Pp
+If the mouse daemon receives the signal
+.Dv SIGUSR1 ,
+it will stop passing mouse events. Sending the signal
+.Dv SIGUSR1
+again will resume passing mouse events. Useful if your typing on a laptop is
+interrupted by accidentally touching the mouse pad.
+.Pp
The following options are available:
.Bl -tag -width indent
.It Fl 3
@@ -703,6 +709,19 @@ This will effectively swap the left and right buttons.
.Pp
Report negative Z axis movement (i.e., mouse wheel) as the button 4 pressed
and positive Z axis movement (i.e., mouse wheel) as the button 5 pressed.
+.Pp
+If you add
+.Pp
+.Dl ALL ALL = NOPASSWD: /usr/bin/killall -USR1 moused
+.Pp
+to your
+.Pa /usr/local/etc/sudoers
+file, and bind
+.Pp
+.Dl killall -USR1 moused
+.Pp
+to a key in your window manager, you can suspend mouse events on your laptop if
+you keep brushing over the mouse pad while typing.
.Sh CAVEATS
The
.Nm
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;
OpenPOWER on IntegriCloud