aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjkim <jkim@FreeBSD.org>2009-02-05 02:31:01 +0800
committerjkim <jkim@FreeBSD.org>2009-02-05 02:31:01 +0800
commit161a00feb6e1b5fa00c6de050ea0c11d92cefca5 (patch)
treef1b8b8ef358e9f7b5ee42659935070755732966d
parentb6a67e386f739419759c8f473316651e5c0cad07 (diff)
downloadfreebsd-ports-gnome-161a00feb6e1b5fa00c6de050ea0c11d92cefca5.tar.gz
freebsd-ports-gnome-161a00feb6e1b5fa00c6de050ea0c11d92cefca5.tar.zst
freebsd-ports-gnome-161a00feb6e1b5fa00c6de050ea0c11d92cefca5.zip
- Replace open(2)/close(2) pairs with stat(2). Closing mouse device has
a side effect of changing current operation level and sysmouse(4) lets you open /dev/sysmouse multiple times unlike other mouse drivers. - Check if /dev/mouse is linked to /dev/psm0 or /dev/ums0. - Simplify the patches a little while I am here.
-rw-r--r--x11-drivers/xf86-input-mouse/Makefile2
-rw-r--r--x11-drivers/xf86-input-mouse/files/patch-src-bsd_mouse.c88
-rw-r--r--x11-servers/xorg-server/Makefile2
-rw-r--r--x11-servers/xorg-server/files/patch-Xserver-hw-xfree86-os-support-bsd-bsd_mouse.c88
4 files changed, 124 insertions, 56 deletions
diff --git a/x11-drivers/xf86-input-mouse/Makefile b/x11-drivers/xf86-input-mouse/Makefile
index a664fce07084..6ed990c4a785 100644
--- a/x11-drivers/xf86-input-mouse/Makefile
+++ b/x11-drivers/xf86-input-mouse/Makefile
@@ -7,7 +7,7 @@
PORTNAME= xf86-input-mouse
PORTVERSION= 1.4.0
-PORTREVISION= 2
+PORTREVISION= 3
CATEGORIES= x11-drivers
MAINTAINER= x11@FreeBSD.org
diff --git a/x11-drivers/xf86-input-mouse/files/patch-src-bsd_mouse.c b/x11-drivers/xf86-input-mouse/files/patch-src-bsd_mouse.c
index b3912fba9cea..03e0b94bab9c 100644
--- a/x11-drivers/xf86-input-mouse/files/patch-src-bsd_mouse.c
+++ b/x11-drivers/xf86-input-mouse/files/patch-src-bsd_mouse.c
@@ -1,5 +1,5 @@
--- src/bsd_mouse.c.orig 2008-11-26 23:11:36.000000000 -0500
-+++ src/bsd_mouse.c 2009-02-02 15:44:07.000000000 -0500
++++ src/bsd_mouse.c 2009-02-04 12:56:32.000000000 -0500
@@ -1,4 +1,3 @@
-
/*
@@ -65,29 +65,25 @@
int i;
mousehw_t hw;
mousemode_t mode;
-@@ -190,10 +216,20 @@
+@@ -190,10 +216,16 @@
if (pInfo->fd == -1)
return NULL;
+#ifdef XPS2_SUPPORT
/* set the driver operation level, if applicable */
-+ if ((dev = xf86FindOptionValue(pInfo->options, "Device"))) {
-+ if (!strncmp(dev, DEFAULT_PS2_DEV, 8))
-+ i = 2;
-+ else
-+ i = 1;
-+ ioctl(pInfo->fd, MOUSE_SETLEVEL, &i);
-+ }
-+#else
++ dev = xf86FindOptionValue(pInfo->options, "Device");
++ if (dev != NULL && !strncmp(dev, DEFAULT_PS2_DEV, 8))
++ i = 2;
++ else
++#endif
i = 1;
ioctl(pInfo->fd, MOUSE_SETLEVEL, &i);
-
-+#endif
+
/* interrogate the driver and get some intelligence on the device. */
hw.iftype = MOUSE_IF_UNKNOWN;
hw.model = MOUSE_MODEL_GENERIC;
-@@ -209,9 +245,18 @@
+@@ -209,9 +241,18 @@
protoPara[0] = mode.syncmask[0];
protoPara[1] = mode.syncmask[1];
}
@@ -108,7 +104,7 @@
}
}
}
-@@ -234,41 +279,41 @@
+@@ -234,41 +275,41 @@
(protocol && xf86NameCmp(protocol, "SysMouse") == 0)) {
/*
* As the FreeBSD sysmouse driver defaults to protocol level 0
@@ -167,10 +163,48 @@
}
return FALSE;
}
-@@ -308,15 +353,23 @@
+@@ -276,17 +317,17 @@
+ static const char *
+ FindDevice(InputInfoPtr pInfo, const char *protocol, int flags)
+ {
+- int fd = -1;
++ int ret = -1;
+ const char **pdev, *dev = NULL;
+ Bool devMouse = FALSE;
+ struct stat devMouseStat;
+ struct stat sb;
+
+ for (pdev = mouseDevs; *pdev; pdev++) {
+- SYSCALL (fd = open(*pdev, O_RDWR | O_NONBLOCK));
+- if (fd == -1) {
++ SYSCALL (ret = stat(*pdev, &sb));
++ if (ret == -1) {
+ #ifdef DEBUG
+- ErrorF("Cannot open %s (%s)\n", *pdev, strerror(errno));
++ ErrorF("Cannot stat %s (%s)\n", *pdev, strerror(errno));
+ #endif
+ } else {
+ /*
+@@ -295,28 +336,32 @@
+ * the test for whether /dev/sysmouse is usable can be made.
+ */
+ if (!strcmp(*pdev, DEFAULT_MOUSE_DEV)) {
+- if (fstat(fd, &devMouseStat) == 0)
+- devMouse = TRUE;
+- close(fd);
++ memcpy(&devMouseStat, &sb, sizeof(devMouseStat));
++ devMouse = TRUE;
+ continue;
+ } else if (!strcmp(*pdev, DEFAULT_SYSMOUSE_DEV)) {
+ /* Check if /dev/mouse is the same as /dev/sysmouse. */
+- if (devMouse && fstat(fd, &sb) == 0 &&
+- devMouseStat.st_dev == sb.st_dev &&
++ if (devMouse && devMouseStat.st_dev == sb.st_dev &&
+ devMouseStat.st_ino == sb.st_ino) {
+ /* If the same, use /dev/sysmouse. */
devMouse = FALSE;
}
- close(fd);
+- close(fd);
- if (MousedRunning())
+ if (MousedRunning(NULL))
break;
@@ -180,24 +214,24 @@
-#endif
- }
} else {
- close(fd);
-+ /*
-+ * If moused(8) owns the device, open(2) should have failed
-+ * but just in case...
-+ */
+- close(fd);
++ /* Check if /dev/mouse is the same as this device. */
++ if (devMouse && devMouseStat.st_dev == sb.st_dev &&
++ devMouseStat.st_ino == sb.st_ino) {
++ /* If the same, use this device. */
++ devMouse = FALSE;
++ }
+ if (MousedRunning(*pdev))
+ continue;
-+ /*
-+ * ums(4) does not support anything but SysMouse protocol.
-+ */
++ /* ums(4) does not support anything but SysMouse protocol. */
+ if (!strncmp(*pdev, DEFAULT_USB_DEV, 8) && protocol &&
-+ strcasecmp(protocol, "auto") &&
-+ strcasecmp(protocol, "sysmouse"))
-+ continue;
++ xf86NameCmp(protocol, "auto") != 0 &&
++ xf86NameCmp(protocol, "sysmouse") != 0)
++ continue;
break;
}
}
-@@ -782,7 +835,9 @@
+@@ -782,7 +827,9 @@
p->CheckProtocol = CheckProtocol;
#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)) && defined(MOUSE_PROTO_SYSMOUSE)
p->SetupAuto = SetupAuto;
diff --git a/x11-servers/xorg-server/Makefile b/x11-servers/xorg-server/Makefile
index 03602f20ab0b..133cbc7caa3f 100644
--- a/x11-servers/xorg-server/Makefile
+++ b/x11-servers/xorg-server/Makefile
@@ -8,7 +8,7 @@
PORTNAME= xorg-server
PORTVERSION= 1.5.3
PORTEPOCH= 1
-PORTREVISION= 3
+PORTREVISION= 4
CATEGORIES= x11-servers
MASTER_SITES= http://xorg.freedesktop.org/releases/individual/xserver/
DISTFILES= xorg-server-${PORTVERSION}.tar.bz2
diff --git a/x11-servers/xorg-server/files/patch-Xserver-hw-xfree86-os-support-bsd-bsd_mouse.c b/x11-servers/xorg-server/files/patch-Xserver-hw-xfree86-os-support-bsd-bsd_mouse.c
index ebfb02c8e37b..4d6e1f91b1f2 100644
--- a/x11-servers/xorg-server/files/patch-Xserver-hw-xfree86-os-support-bsd-bsd_mouse.c
+++ b/x11-servers/xorg-server/files/patch-Xserver-hw-xfree86-os-support-bsd-bsd_mouse.c
@@ -1,5 +1,5 @@
--- hw/xfree86/os-support/bsd/bsd_mouse.c.orig 2008-11-05 11:52:17.000000000 -0500
-+++ hw/xfree86/os-support/bsd/bsd_mouse.c 2009-02-02 15:56:11.000000000 -0500
++++ hw/xfree86/os-support/bsd/bsd_mouse.c 2009-02-04 12:54:48.000000000 -0500
@@ -1,4 +1,3 @@
-
/*
@@ -65,29 +65,25 @@
int i;
mousehw_t hw;
mousemode_t mode;
-@@ -191,10 +217,20 @@
+@@ -191,10 +217,16 @@
if (pInfo->fd == -1)
return NULL;
+#ifdef XPS2_SUPPORT
/* set the driver operation level, if applicable */
-+ if ((dev = xf86FindOptionValue(pInfo->options, "Device"))) {
-+ if (!strncmp(dev, DEFAULT_PS2_DEV, 8))
-+ i = 2;
-+ else
-+ i = 1;
-+ ioctl(pInfo->fd, MOUSE_SETLEVEL, &i);
-+ }
-+#else
++ dev = xf86FindOptionValue(pInfo->options, "Device");
++ if (dev != NULL && !strncmp(dev, DEFAULT_PS2_DEV, 8))
++ i = 2;
++ else
++#endif
i = 1;
ioctl(pInfo->fd, MOUSE_SETLEVEL, &i);
-
-+#endif
+
/* interrogate the driver and get some intelligence on the device. */
hw.iftype = MOUSE_IF_UNKNOWN;
hw.model = MOUSE_MODEL_GENERIC;
-@@ -210,9 +246,18 @@
+@@ -210,9 +242,18 @@
protoPara[0] = mode.syncmask[0];
protoPara[1] = mode.syncmask[1];
}
@@ -108,7 +104,7 @@
}
}
}
-@@ -235,41 +280,41 @@
+@@ -235,41 +276,41 @@
(protocol && xf86NameCmp(protocol, "SysMouse") == 0)) {
/*
* As the FreeBSD sysmouse driver defaults to protocol level 0
@@ -167,10 +163,48 @@
}
return FALSE;
}
-@@ -309,15 +354,23 @@
+@@ -277,17 +318,17 @@
+ static const char *
+ FindDevice(InputInfoPtr pInfo, const char *protocol, int flags)
+ {
+- int fd = -1;
++ int ret = -1;
+ const char **pdev, *dev = NULL;
+ Bool devMouse = FALSE;
+ struct stat devMouseStat;
+ struct stat sb;
+
+ for (pdev = mouseDevs; *pdev; pdev++) {
+- SYSCALL (fd = open(*pdev, O_RDWR | O_NONBLOCK));
+- if (fd == -1) {
++ SYSCALL (ret = stat(*pdev, &sb));
++ if (ret == -1) {
+ #ifdef DEBUG
+- ErrorF("Cannot open %s (%s)\n", *pdev, strerror(errno));
++ ErrorF("Cannot stat %s (%s)\n", *pdev, strerror(errno));
+ #endif
+ } else {
+ /*
+@@ -296,28 +337,32 @@
+ * the test for whether /dev/sysmouse is usable can be made.
+ */
+ if (!strcmp(*pdev, DEFAULT_MOUSE_DEV)) {
+- if (fstat(fd, &devMouseStat) == 0)
+- devMouse = TRUE;
+- close(fd);
++ memcpy(&devMouseStat, &sb, sizeof(devMouseStat));
++ devMouse = TRUE;
+ continue;
+ } else if (!strcmp(*pdev, DEFAULT_SYSMOUSE_DEV)) {
+ /* Check if /dev/mouse is the same as /dev/sysmouse. */
+- if (devMouse && fstat(fd, &sb) == 0 &&
+- devMouseStat.st_dev == sb.st_dev &&
++ if (devMouse && devMouseStat.st_dev == sb.st_dev &&
+ devMouseStat.st_ino == sb.st_ino) {
+ /* If the same, use /dev/sysmouse. */
devMouse = FALSE;
}
- close(fd);
+- close(fd);
- if (MousedRunning())
+ if (MousedRunning(NULL))
break;
@@ -180,24 +214,24 @@
-#endif
- }
} else {
- close(fd);
-+ /*
-+ * If moused(8) owns the device, open(2) should have failed
-+ * but just in case...
-+ */
+- close(fd);
++ /* Check if /dev/mouse is the same as this device. */
++ if (devMouse && devMouseStat.st_dev == sb.st_dev &&
++ devMouseStat.st_ino == sb.st_ino) {
++ /* If the same, use this device. */
++ devMouse = FALSE;
++ }
+ if (MousedRunning(*pdev))
+ continue;
-+ /*
-+ * ums(4) does not support anything but SysMouse protocol.
-+ */
++ /* ums(4) does not support anything but SysMouse protocol. */
+ if (!strncmp(*pdev, DEFAULT_USB_DEV, 8) && protocol &&
-+ strcasecmp(protocol, "auto") &&
-+ strcasecmp(protocol, "sysmouse"))
-+ continue;
++ xf86NameCmp(protocol, "auto") != 0 &&
++ xf86NameCmp(protocol, "sysmouse") != 0)
++ continue;
break;
}
}
-@@ -775,7 +828,9 @@
+@@ -775,7 +820,9 @@
p->CheckProtocol = CheckProtocol;
#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)) && defined(MOUSE_PROTO_SYSMOUSE)
p->SetupAuto = SetupAuto;