summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2011-03-21 11:23:34 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2011-04-04 09:39:10 +1000
commit241254e352f5c4e3d6850e0916261cb235c6b608 (patch)
tree2d994278e959379cf2c9fbb606838effd4760dec
parentf65f8a8365b158cbdb6cdc3f74afc08a2653c084 (diff)
Don't autoprobe for devices when Option Device is set.
If only Option Device is set but no protocol, the code calls into AutoDevProbe. eventcomm (the only backend with an AutoDevProbe) then runs through all /dev/input/event devices and takes the first one it can find. If two touchpads are connected on a system, this may cause the same touchpad to be added twice and the other one not at all - even though the device path is specified. (This can only happen when the event device is not grabbed, otherwise the grabcheck prevents the touchpad from being added twice) Pass the device option into AutoDevProbe and check that device first. If it is a touchpad, finish with success. If it isn't, fail AutoDevProbe. Introduced in dce6006f6a851be4147e16731caa453dd0d1ec1c. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> CC: Alexandr Shadchin <alexandr.shadchin@gmail.com> Reviewed-by: Chris Bagwell <chris@cnpbagwell.com>
-rw-r--r--src/eventcomm.c18
-rw-r--r--src/synaptics.c2
-rw-r--r--src/synproto.h2
3 files changed, 19 insertions, 3 deletions
diff --git a/src/eventcomm.c b/src/eventcomm.c
index 0215269..30007ab 100644
--- a/src/eventcomm.c
+++ b/src/eventcomm.c
@@ -504,7 +504,7 @@ EventReadDevDimensions(InputInfoPtr pInfo)
}
static Bool
-EventAutoDevProbe(InputInfoPtr pInfo)
+EventAutoDevProbe(InputInfoPtr pInfo, const char *device)
{
/* We are trying to find the right eventX device or fall back to
the psaux protocol and the given device from XF86Config */
@@ -512,6 +512,22 @@ EventAutoDevProbe(InputInfoPtr pInfo)
Bool touchpad_found = FALSE;
struct dirent **namelist;
+ if (device) {
+ int fd = -1;
+ SYSCALL(fd = open(device, O_RDONLY));
+ if (fd >= 0)
+ {
+ touchpad_found = event_query_is_touchpad(fd, TRUE);
+
+ SYSCALL(close(fd));
+ /* if a device is set and not a touchpad (or already grabbed),
+ * we must return FALSE. Otherwise, we'll add a device that
+ * wasn't requested for and repeat
+ * f5687a6741a19ef3081e7fd83ac55f6df8bcd5c2. */
+ return touchpad_found;
+ }
+ }
+
i = scandir(DEV_INPUT_EVENT, &namelist, EventDevOnly, alphasort);
if (i < 0) {
xf86Msg(X_ERROR, "Couldn't open %s\n", DEV_INPUT_EVENT);
diff --git a/src/synaptics.c b/src/synaptics.c
index 1233917..102a701 100644
--- a/src/synaptics.c
+++ b/src/synaptics.c
@@ -261,7 +261,7 @@ SetDeviceAndProtocol(InputInfoPtr pInfo)
for (i = 0; protocols[i].name; i++) {
if ((!device || !proto) &&
protocols[i].proto_ops->AutoDevProbe &&
- protocols[i].proto_ops->AutoDevProbe(pInfo))
+ protocols[i].proto_ops->AutoDevProbe(pInfo, device))
break;
else if (proto && !strcmp(proto, protocols[i].name))
break;
diff --git a/src/synproto.h b/src/synproto.h
index 251dc84..75f90e4 100644
--- a/src/synproto.h
+++ b/src/synproto.h
@@ -75,7 +75,7 @@ struct SynapticsProtocolOperations {
Bool (*QueryHardware)(InputInfoPtr pInfo);
Bool (*ReadHwState)(InputInfoPtr pInfo,
struct CommData *comm, struct SynapticsHwState *hwRet);
- Bool (*AutoDevProbe)(InputInfoPtr pInfo);
+ Bool (*AutoDevProbe)(InputInfoPtr pInfo, const char *device);
void (*ReadDevDimensions)(InputInfoPtr pInfo);
};