[PATCH] xfree86: rename allowEmptyInput to forceInputDevices.

Peter Hutterer peter.hutterer at who-t.net
Wed Nov 10 19:43:13 PST 2010


This is a more accurate name for the actual functionality than
allowEmptyInput. Historically, allowEmptyInput has allowed the server to
start with no input devices. Since 1.4 and the introduction of VCP and VCK,
there are always two input devices present.

allowEmptyInput was changed in behaviour to essentially "ignore xorg.conf
devices or not", auto-adding the built-in devices if disabled.

Rename to forceInputDevices, because that's essentially what it does. When
disabled (i.e. when hotplugging is enabled), it disables all
mouse/kbd/vmmouse devices configured in the xorg.conf file.
When enabled, it forces the traditional behaviour for input devices:
- use input devices configured in the server layout
- if none are configured, use the first pointer and the first keyboard
  device in the xorg.conf
- if none are configured, create the default pointer/keyboard devices.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 hw/xfree86/common/xf86Config.c         |   36 ++++++++++++++++---------------
 hw/xfree86/common/xf86Globals.c        |    4 +-
 hw/xfree86/common/xf86Privstr.h        |    3 +-
 hw/xfree86/os-support/linux/lnx_init.c |    2 +-
 4 files changed, 23 insertions(+), 22 deletions(-)

diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index 88e2e8d..e30a2bf 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -952,12 +952,13 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
     }
 #endif
 
-    /* AllowEmptyInput is automatically true if we're hotplugging */
-    xf86Info.allowEmptyInput = (xf86Info.autoAddDevices && xf86Info.autoEnableDevices);
+    /* if we're not hotplugging, force some input devices to exist */
+    xf86Info.forceInputDevices = !(xf86Info.autoAddDevices && xf86Info.autoEnableDevices);
 
-    /* AEI on? Then we're not using kbd, so use the evdev rules set. */
+    /* when forcing input devices, we use kbd. otherwise evdev, so use the
+     * evdev rules set. */
 #if defined(linux)
-    if (xf86Info.allowEmptyInput)
+    if (!xf86Info.forceInputDevices)
         set.rules = "evdev";
 #endif
     XkbSetRulesDflts(&set);
@@ -1196,7 +1197,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
     }
 
     /* 3. First core pointer device. */
-    if (!foundPointer && (!xf86Info.allowEmptyInput || implicitLayout)) {
+    if (!foundPointer && (xf86Info.forceInputDevices || implicitLayout)) {
 	XF86ConfInputPtr p;
 
 	for (p = xf86configptr->conf_input_lst; p; p = p->list.next) {
@@ -1212,7 +1213,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
     }
 
     /* 4. First pointer with an allowed mouse driver. */
-    if (!foundPointer && !xf86Info.allowEmptyInput) {
+    if (!foundPointer && xf86Info.forceInputDevices) {
 	const char **driver = mousedrivers;
 	confInput = xf86findInput(CONF_IMPLICIT_POINTER,
 				  xf86configptr->conf_input_lst);
@@ -1229,7 +1230,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
     }
 
     /* 5. Built-in default. */
-    if (!foundPointer && !xf86Info.allowEmptyInput) {
+    if (!foundPointer && xf86Info.forceInputDevices) {
 	memset(&defPtr, 0, sizeof(defPtr));
 	defPtr.inp_identifier = strdup("<default pointer>");
 	defPtr.inp_driver = strdup("mouse");
@@ -1255,7 +1256,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
 	}
     }
 
-    if (!foundPointer && !xf86Info.allowEmptyInput) {
+    if (!foundPointer && xf86Info.forceInputDevices) {
 	/* This shouldn't happen. */
 	xf86Msg(X_ERROR, "Cannot locate a core pointer device.\n");
 	return FALSE;
@@ -1279,7 +1280,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
 	    driver++;
 	}
     }
-    if (!found && !xf86Info.allowEmptyInput) {
+    if (!found && xf86Info.forceInputDevices) {
 	xf86Msg(X_INFO, "No default mouse found, adding one\n");
 	memset(&defPtr, 0, sizeof(defPtr));
 	defPtr.inp_identifier = strdup("<default pointer>");
@@ -1338,7 +1339,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
     }
 
     /* 3. First core keyboard device. */
-    if (!foundKeyboard && (!xf86Info.allowEmptyInput || implicitLayout)) {
+    if (!foundKeyboard && (xf86Info.forceInputDevices || implicitLayout)) {
 	XF86ConfInputPtr p;
 
 	for (p = xf86configptr->conf_input_lst; p; p = p->list.next) {
@@ -1354,7 +1355,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
     }
 
     /* 4. First keyboard with 'keyboard' or 'kbd' as the driver. */
-    if (!foundKeyboard && !xf86Info.allowEmptyInput) {
+    if (!foundKeyboard && xf86Info.forceInputDevices) {
 	confInput = xf86findInput(CONF_IMPLICIT_KEYBOARD,
 				  xf86configptr->conf_input_lst);
 	if (!confInput) {
@@ -1369,7 +1370,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
     }
 
     /* 5. Built-in default. */
-    if (!foundKeyboard && !xf86Info.allowEmptyInput) {
+    if (!foundKeyboard && xf86Info.forceInputDevices) {
 	memset(&defKbd, 0, sizeof(defKbd));
 	defKbd.inp_identifier = strdup("<default keyboard>");
 	defKbd.inp_driver = strdup("kbd");
@@ -1395,7 +1396,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
 	}
     }
 
-    if (!foundKeyboard && !xf86Info.allowEmptyInput) {
+    if (!foundKeyboard && xf86Info.forceInputDevices) {
 	/* This shouldn't happen. */
 	xf86Msg(X_ERROR, "Cannot locate a core keyboard device.\n");
 	return FALSE;
@@ -1421,7 +1422,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
 	            "\tUsing the %s.\n", keyboardMsg);
     }
 
-    if (xf86Info.allowEmptyInput && !(foundPointer && foundKeyboard)) {
+    if (!xf86Info.forceInputDevices && !(foundPointer && foundKeyboard)) {
 #if defined(CONFIG_HAL) || defined(CONFIG_UDEV)
 	const char *config_backend;
 #if defined(CONFIG_HAL)
@@ -2335,10 +2336,11 @@ 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.
+    /* Unless we're forcing input devices, disable mouse/kbd devices in the
+     * config. Otherwise the same physical device is added multiple times,
+     * leading to duplicate events.
      */
-    if (xf86Info.allowEmptyInput && layout->inputs)
+    if (!xf86Info.forceInputDevices && layout->inputs)
     {
         IDevPtr *dev = layout->inputs;
         BOOL warned = FALSE;
diff --git a/hw/xfree86/common/xf86Globals.c b/hw/xfree86/common/xf86Globals.c
index 781ee49..fe42a9e 100644
--- a/hw/xfree86/common/xf86Globals.c
+++ b/hw/xfree86/common/xf86Globals.c
@@ -129,11 +129,11 @@ xf86InfoRec xf86Info = {
     .disableRandR               = FALSE,
     .randRFrom                  = X_DEFAULT,
 #if defined(CONFIG_HAL) || defined(CONFIG_UDEV)
-    .allowEmptyInput            = TRUE,
+    .forceInputDevices          = FALSE,
     .autoAddDevices             = TRUE,
     .autoEnableDevices          = TRUE
 #else
-    .allowEmptyInput            = FALSE,
+    .forceInputDevices          = TRUE,
     .autoAddDevices             = FALSE,
     .autoEnableDevices          = FALSE
 #endif
diff --git a/hw/xfree86/common/xf86Privstr.h b/hw/xfree86/common/xf86Privstr.h
index 39cd230..9608792 100644
--- a/hw/xfree86/common/xf86Privstr.h
+++ b/hw/xfree86/common/xf86Privstr.h
@@ -108,8 +108,7 @@ typedef struct {
     MessageType		useDefaultFontPathFrom;
     Bool        ignoreABI;
 
-    Bool        allowEmptyInput;  /* Allow the server to start with no input
-                                   * devices. */
+    Bool        forceInputDevices; /* force xorg.conf or built-in input devices */
     Bool        autoAddDevices; /* Whether to succeed NIDR, or ignore. */
     Bool        autoEnableDevices; /* Whether to enable, or let the client
                                     * control. */
diff --git a/hw/xfree86/os-support/linux/lnx_init.c b/hw/xfree86/os-support/linux/lnx_init.c
index 92bfde4..6a3e5b1 100644
--- a/hw/xfree86/os-support/linux/lnx_init.c
+++ b/hw/xfree86/os-support/linux/lnx_init.c
@@ -277,7 +277,7 @@ xf86OpenConsole(void)
             tcsetattr(xf86Info.consoleFd, TCSANOW, &nTty);
 
             /* need to keep the buffer clean, else the kernel gets angry */
-	    if (xf86Info.allowEmptyInput)
+	    if (!xf86Info.forceInputDevices)
 		console_handler = xf86AddGeneralHandler(xf86Info.consoleFd,
 							drain_console, NULL);
 
-- 
1.7.3.2


More information about the xorg-devel mailing list