xfree86: use xorg.conf input devices if there is no ServerLayout

If xorg.conf has no ServerLayout section, use the first mouse and
keyboard sections as core devices, even with AllowEmptyInput.
This commit is contained in:
Julien Cristau 2008-07-26 15:35:42 +02:00
parent 805f28e96c
commit 2eaed4a10f

View File

@ -1315,7 +1315,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
}
/* 3. First core pointer device. */
if (!foundPointer) {
if (!foundPointer && (!xf86Info.allowEmptyInput || implicitLayout)) {
XF86ConfInputPtr p;
for (p = xf86configptr->conf_input_lst; p; p = p->list.next) {
@ -1331,7 +1331,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
}
/* 4. First pointer with 'mouse' as the driver. */
if (!foundPointer) {
if (!foundPointer && (!xf86Info.allowEmptyInput || implicitLayout)) {
confInput = xf86findInput(CONF_IMPLICIT_POINTER,
xf86configptr->conf_input_lst);
if (!confInput) {
@ -1346,7 +1346,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
}
/* 5. Built-in default. */
if (!foundPointer) {
if (!foundPointer && !xf86Info.allowEmptyInput) {
bzero(&defPtr, sizeof(defPtr));
defPtr.inp_identifier = strdup("<default pointer>");
defPtr.inp_driver = strdup("mouse");
@ -1373,9 +1373,13 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
}
if (!foundPointer) {
/* This shouldn't happen. */
xf86Msg(X_ERROR, "Cannot locate a core pointer device.\n");
return FALSE;
if (!xf86Info.allowEmptyInput) {
/* This shouldn't happen. */
xf86Msg(X_ERROR, "Cannot locate a core pointer device.\n");
return FALSE;
} else {
xf86Msg(X_INFO, "Cannot locate a core pointer device.\n");
}
}
/*
@ -1392,7 +1396,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
found = 1; break;
}
}
if (!found) {
if (!found && !xf86Info.allowEmptyInput) {
xf86Msg(X_INFO, "No default mouse found, adding one\n");
bzero(&defPtr, sizeof(defPtr));
defPtr.inp_identifier = strdup("<default pointer>");
@ -1451,7 +1455,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
}
/* 3. First core keyboard device. */
if (!foundKeyboard) {
if (!foundKeyboard && (!xf86Info.allowEmptyInput || implicitLayout)) {
XF86ConfInputPtr p;
for (p = xf86configptr->conf_input_lst; p; p = p->list.next) {
@ -1467,7 +1471,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
}
/* 4. First keyboard with 'keyboard' or 'kbd' as the driver. */
if (!foundKeyboard) {
if (!foundKeyboard && (!xf86Info.allowEmptyInput || implicitLayout)) {
confInput = xf86findInput(CONF_IMPLICIT_KEYBOARD,
xf86configptr->conf_input_lst);
if (!confInput) {
@ -1482,7 +1486,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
}
/* 5. Built-in default. */
if (!foundKeyboard) {
if (!foundKeyboard && !xf86Info.allowEmptyInput) {
bzero(&defKbd, sizeof(defKbd));
defKbd.inp_identifier = strdup("<default keyboard>");
defKbd.inp_driver = strdup("kbd");
@ -1509,21 +1513,39 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
}
if (!foundKeyboard) {
/* This shouldn't happen. */
xf86Msg(X_ERROR, "Cannot locate a core keyboard device.\n");
return FALSE;
if (!xf86Info.allowEmptyInput) {
/* This shouldn't happen. */
xf86Msg(X_ERROR, "Cannot locate a core keyboard device.\n");
return FALSE;
} else {
xf86Msg(X_INFO, "Cannot locate a core keyboard device.\n");
}
}
if (pointerMsg) {
xf86Msg(X_DEFAULT, "The core pointer device wasn't specified "
"explicitly in the layout.\n"
"\tUsing the %s.\n", pointerMsg);
if (implicitLayout)
xf86Msg(X_DEFAULT, "No Layout section. Using the %s.\n",
pointerMsg);
else
xf86Msg(X_DEFAULT, "The core pointer device wasn't specified "
"explicitly in the layout.\n"
"\tUsing the %s.\n", pointerMsg);
}
if (keyboardMsg) {
xf86Msg(X_DEFAULT, "The core keyboard device wasn't specified "
"explicitly in the layout.\n"
"\tUsing the %s.\n", keyboardMsg);
if (implicitLayout)
xf86Msg(X_DEFAULT, "No Layout section. Using the %s.\n",
keyboardMsg);
else
xf86Msg(X_DEFAULT, "The core keyboard device wasn't specified "
"explicitly in the layout.\n"
"\tUsing the %s.\n", keyboardMsg);
}
if (xf86Info.allowEmptyInput && !(foundPointer && foundKeyboard)) {
xf86Msg(X_INFO, "The server relies on HAL to provide the list of "
"input devices.\n\tIf no devices become available, "
"reconfigure HAL or disable AllowEmptyInput.\n");
}
return TRUE;
@ -2470,26 +2492,8 @@ addDefaultModes(MonPtr monitorp)
}
static void
checkInput(serverLayoutPtr layout) {
if (!xf86Info.allowEmptyInput)
checkCoreInputDevices(layout, FALSE);
else
{
xf86Msg(X_INFO, "AllowEmptyInput is on.\n"
"\tThe server relies on HAL to provide the list of input "
"devices.\n\tIf no devices become available, reconfigure "
"HAL.\n");
if (!layout->inputs || !*layout->inputs)
{
/* No input device specified in ServerLayout. */
if (xf86configptr->conf_input_lst &&
xf86configptr->conf_input_lst->inp_identifier)
xf86Msg(X_WARNING, "Input devices specified in xorg.conf, but"
" not referenced in ServerLayout.\n\tThese devices"
" will NOT be available.\n");
}
}
checkInput(serverLayoutPtr layout, Bool implicit_layout) {
checkCoreInputDevices(layout, implicit_layout);
}
/*
@ -2503,6 +2507,7 @@ xf86HandleConfigFile(Bool autoconfig)
MessageType from = X_DEFAULT;
char *scanptr;
Bool singlecard = 0;
Bool implicit_layout = FALSE;
if (!autoconfig) {
if (getuid() == 0)
@ -2555,6 +2560,7 @@ xf86HandleConfigFile(Bool autoconfig)
xf86Msg(X_ERROR, "Unable to determine the screen layout\n");
return CONFIG_PARSE_ERROR;
}
implicit_layout = TRUE;
} else {
if (xf86configptr->conf_flags != NULL) {
char *dfltlayout = NULL;
@ -2612,7 +2618,7 @@ xf86HandleConfigFile(Bool autoconfig)
configDRI(xf86configptr->conf_dri);
#endif
checkInput(&xf86ConfigLayout);
checkInput(&xf86ConfigLayout, implicit_layout);
/*
* Handle some command line options that can override some of the