summaryrefslogtreecommitdiffstats
path: root/sys/dev/syscons
diff options
context:
space:
mode:
authorhselasky <hselasky@FreeBSD.org>2013-02-06 11:16:18 +0000
committerhselasky <hselasky@FreeBSD.org>2013-02-06 11:16:18 +0000
commit7280eb0924ffd1922c50d6f2fafbd523b47c9210 (patch)
tree40018f7be050f03a6e369541706b2074183a0035 /sys/dev/syscons
parent40a2400cbed1f40f70252328eeb5d4001f0a6fbb (diff)
downloadFreeBSD-src-7280eb0924ffd1922c50d6f2fafbd523b47c9210.zip
FreeBSD-src-7280eb0924ffd1922c50d6f2fafbd523b47c9210.tar.gz
Make sure that all mouse buttons are released when clients
using /dev/consolectl close. This fixes a problem where if a USB mouse is detached while a button is pressed, that button is never released. MFC after: 1 week
Diffstat (limited to 'sys/dev/syscons')
-rw-r--r--sys/dev/syscons/syscons.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/sys/dev/syscons/syscons.c b/sys/dev/syscons/syscons.c
index beb0c67..8094ea3 100644
--- a/sys/dev/syscons/syscons.c
+++ b/sys/dev/syscons/syscons.c
@@ -253,11 +253,13 @@ static struct ttydevsw sc_ttydevsw = {
};
static d_ioctl_t consolectl_ioctl;
+static d_close_t consolectl_close;
static struct cdevsw consolectl_devsw = {
.d_version = D_VERSION,
- .d_flags = D_NEEDGIANT,
+ .d_flags = D_NEEDGIANT | D_TRACKCLOSE,
.d_ioctl = consolectl_ioctl,
+ .d_close = consolectl_close,
.d_name = "consolectl",
};
@@ -1561,6 +1563,23 @@ consolectl_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag,
return sctty_ioctl(dev->si_drv1, cmd, data, td);
}
+static int
+consolectl_close(struct cdev *dev, int flags, int mode, struct thread *td)
+{
+#ifndef SC_NO_SYSMOUSE
+ mouse_info_t info;
+ memset(&info, 0, sizeof(info));
+ info.operation = MOUSE_ACTION;
+
+ /*
+ * Make sure all buttons are released when moused and other
+ * console daemons exit, so that no buttons are left pressed.
+ */
+ (void) sctty_ioctl(dev->si_drv1, CONS_MOUSECTL, (caddr_t)&info, td);
+#endif
+ return (0);
+}
+
static void
sc_cnprobe(struct consdev *cp)
{
OpenPOWER on IntegriCloud