ea13437
From d3863202cba03fe564d6cc1fe3641f017392c9e7 Mon Sep 17 00:00:00 2001
672b9fa
From: Peter Hutterer <peter.hutterer@redhat.com>
672b9fa
Date: Thu, 16 Oct 2008 11:22:29 +1030
672b9fa
Subject: [PATCH] xfree86: If AEI is on, disable "kbd" and "mouse" devices.
672b9fa
672b9fa
This consists of two parts:
672b9fa
In the implicit server layout, ignore those drivers when looking for a core
672b9fa
device.
672b9fa
672b9fa
And after finishing the server layout, run through the list of devices and
672b9fa
remove any that use mouse or kbd.
672b9fa
672b9fa
AEI is mutually exclusive with the kbd and mouse drivers, so pick either - or.
ea13437
If no config file is present, force AEI on.
672b9fa
---
672b9fa
 hw/xfree86/common/xf86Config.c |   39 +++++++++++++++++++++++++++++++++++++--
ea13437
 hw/xfree86/common/xf86Init.c   |    2 ++
ea13437
 2 files changed, 39 insertions(+), 2 deletions(-)
672b9fa
672b9fa
diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
672b9fa
index a1c2e34..ac80add 100644
672b9fa
--- a/hw/xfree86/common/xf86Config.c
672b9fa
+++ b/hw/xfree86/common/xf86Config.c
672b9fa
@@ -1340,7 +1340,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
672b9fa
     }
672b9fa
 
672b9fa
     /* 4. First pointer with 'mouse' as the driver. */
672b9fa
-    if (!foundPointer && (!xf86Info.allowEmptyInput || implicitLayout)) {
672b9fa
+    if (!foundPointer && !xf86Info.allowEmptyInput) {
672b9fa
 	confInput = xf86findInput(CONF_IMPLICIT_POINTER,
672b9fa
 				  xf86configptr->conf_input_lst);
672b9fa
 	if (!confInput) {
672b9fa
@@ -1480,7 +1480,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
672b9fa
     }
672b9fa
 
672b9fa
     /* 4. First keyboard with 'keyboard' or 'kbd' as the driver. */
672b9fa
-    if (!foundKeyboard && (!xf86Info.allowEmptyInput || implicitLayout)) {
672b9fa
+    if (!foundKeyboard && !xf86Info.allowEmptyInput) {
672b9fa
 	confInput = xf86findInput(CONF_IMPLICIT_KEYBOARD,
672b9fa
 				  xf86configptr->conf_input_lst);
672b9fa
 	if (!confInput) {
672b9fa
@@ -2481,6 +2481,41 @@ addDefaultModes(MonPtr monitorp)
672b9fa
 static void
672b9fa
 checkInput(serverLayoutPtr layout, Bool implicit_layout) {
672b9fa
     checkCoreInputDevices(layout, implicit_layout);
672b9fa
+
672b9fa
+    /* AllowEmptyInput and the "kbd" and "mouse" drivers are mutually
672b9fa
+     * exclusive. Trawl the list for mouse/kbd devices and disable them.
672b9fa
+     */
672b9fa
+    if (xf86Info.allowEmptyInput && layout->inputs)
672b9fa
+    {
672b9fa
+        IDevPtr *dev = layout->inputs;
672b9fa
+        BOOL warned = FALSE;
672b9fa
+
672b9fa
+        while(*dev)
672b9fa
+        {
672b9fa
+            if (strcmp((*dev)->driver, "kbd") == 0 ||
672b9fa
+                strcmp((*dev)->driver, "mouse") == 0)
672b9fa
+            {
672b9fa
+                IDevPtr *current;
672b9fa
+                if (!warned)
672b9fa
+                {
672b9fa
+                    xf86Msg(X_WARNING, "AllowEmtpyInput is on, devices using "
672b9fa
+                            "drivers 'kbd' or 'mouse' will be disabled.\n");
672b9fa
+                    warned = TRUE;
672b9fa
+                }
672b9fa
+
672b9fa
+                xf86Msg(X_WARNING, "Disabling %s\n", (*dev)->identifier);
672b9fa
+
672b9fa
+                current = dev;
672b9fa
+                xfree(*dev);
672b9fa
+
672b9fa
+                do {
672b9fa
+                    *current = *(current + 1);
672b9fa
+                    current++;
672b9fa
+                } while(*current);
672b9fa
+            } else
672b9fa
+                dev++;
672b9fa
+        }
672b9fa
+    }
672b9fa
 }
672b9fa
 
672b9fa
 /*
ea13437
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
ea13437
index 68dc387..eb4ebfa 100644
ea13437
--- a/hw/xfree86/common/xf86Init.c
ea13437
+++ b/hw/xfree86/common/xf86Init.c
ea13437
@@ -508,6 +508,8 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
ea13437
 	xf86Msg(X_ERROR, "Error parsing the config file\n");
ea13437
 	return;
ea13437
       case CONFIG_NOFILE:
ea13437
+	/* No config file? Then we want HAL to give us the devices. */
ea13437
+	xf86Info.allowEmptyInput = TRUE;
ea13437
 	autoconfig = TRUE;
ea13437
 	break;
ea13437
       }
672b9fa
-- 
672b9fa
1.6.0.1
672b9fa