mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-11 09:50:12 +00:00
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
This commit is contained in:
parent
c7e7950d2d
commit
9eac5bb9e2
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=153070
@ -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
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user