[PATCH] xfree86: if AllowEmptyInput is true, enable RAW mode on the console.

Peter Hutterer peter.hutterer at who-t.net
Mon Oct 20 16:17:23 PDT 2008


On Mon, Oct 20, 2008 at 03:30:23PM +0200, Julien Cristau wrote:
> Is whatever's in the ServerLayout section really relevant here?  Sounds
> to me that if you have input devices configured in xorg.conf (as you
> used to need before i-h), you upgrade your X server and get i-h enabled,
> then suddenly all your input events will be duplicated.

correct, without the grab, nothing stops you from even opening the same evdev
device multiple times.

> It really seems like we need a way to prevent events from getting to
> /dev/input/mice and the console if evdev deals with them...  I don't
> want to mess with people's xorg.confs more than I have to, and right now
> I don't see any better option than turning Auto{Add,Enable}Devices off
> on upgrade, and that sucks (or forcefully uninstalling kbd and mouse.
> ugh).  Am I missing something obvious?  I'd be glad to know how the
> upgrade from F9 to F10 deals with this, if at all; maybe I can steal
> some ideas. :)

we can't block /dev/input/mice without help from the kernel. and they don't
seem to be that happy about the notion of a two-stage grab.
The patch below disables kbd and mouse devices if AEI is on. Note that the
last hunk isn't needed if we apply the xf86Info patch I sent yesterday
(http://lists.freedesktop.org/archives/xorg/2008-October/039523.html)

This however still gives you duplicates if you have evdev devices in your
xorg.conf.

>From d3863202cba03fe564d6cc1fe3641f017392c9e7 Mon Sep 17 00:00:00 2001
From: Peter Hutterer <peter.hutterer at redhat.com>
Date: Thu, 16 Oct 2008 11:22:29 +1030
Subject: [PATCH] xfree86: If AEI is on, disable "kbd" and "mouse" devices.

This consists of two parts:
In the implicit server layout, ignore those drivers when looking for a core
device.

And after finishing the server layout, run through the list of devices and
remove any that use mouse or kbd.

AEI is mutually exclusive with the kbd and mouse drivers, so pick either - or.
If no config file is present, force AEI on.
---
 hw/xfree86/common/xf86Config.c |   39 +++++++++++++++++++++++++++++++++++++--
 hw/xfree86/common/xf86Init.c   |    2 ++
 2 files changed, 39 insertions(+), 2 deletions(-)

diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index a1c2e34..ac80add 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -1340,7 +1340,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
     }
 
     /* 4. First pointer with 'mouse' as the driver. */
-    if (!foundPointer && (!xf86Info.allowEmptyInput || implicitLayout)) {
+    if (!foundPointer && !xf86Info.allowEmptyInput) {
 	confInput = xf86findInput(CONF_IMPLICIT_POINTER,
 				  xf86configptr->conf_input_lst);
 	if (!confInput) {
@@ -1480,7 +1480,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
     }
 
     /* 4. First keyboard with 'keyboard' or 'kbd' as the driver. */
-    if (!foundKeyboard && (!xf86Info.allowEmptyInput || implicitLayout)) {
+    if (!foundKeyboard && !xf86Info.allowEmptyInput) {
 	confInput = xf86findInput(CONF_IMPLICIT_KEYBOARD,
 				  xf86configptr->conf_input_lst);
 	if (!confInput) {
@@ -2481,6 +2481,41 @@ addDefaultModes(MonPtr monitorp)
 static void
 checkInput(serverLayoutPtr layout, Bool implicit_layout) {
     checkCoreInputDevices(layout, implicit_layout);
+
+    /* AllowEmptyInput and the "kbd" and "mouse" drivers are mutually
+     * exclusive. Trawl the list for mouse/kbd devices and disable them.
+     */
+    if (xf86Info.allowEmptyInput && layout->inputs)
+    {
+        IDevPtr *dev = layout->inputs;
+        BOOL warned = FALSE;
+
+        while(*dev)
+        {
+            if (strcmp((*dev)->driver, "kbd") == 0 ||
+                strcmp((*dev)->driver, "mouse") == 0)
+            {
+                IDevPtr *current;
+                if (!warned)
+                {
+                    xf86Msg(X_WARNING, "AllowEmtpyInput is on, devices using "
+                            "drivers 'kbd' or 'mouse' will be disabled.\n");
+                    warned = TRUE;
+                }
+
+                xf86Msg(X_WARNING, "Disabling %s\n", (*dev)->identifier);
+
+                current = dev;
+                xfree(*dev);
+
+                do {
+                    *current = *(current + 1);
+                    current++;
+                } while(*current);
+            } else
+                dev++;
+        }
+    }
 }
 
 /*
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index 68dc387..eb4ebfa 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -508,6 +508,8 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
 	xf86Msg(X_ERROR, "Error parsing the config file\n");
 	return;
       case CONFIG_NOFILE:
+	/* No config file? Then we want HAL to give us the devices. */
+	xf86Info.allowEmptyInput = TRUE;
 	autoconfig = TRUE;
 	break;
       }
-- 
1.6.0.1





More information about the xorg mailing list