xfree86: use xf86AllocateInput for implicit devices too

Slowly merging the vastly different code-paths.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
This commit is contained in:
Peter Hutterer 2011-07-08 16:10:07 +10:00
parent fa8f465281
commit 95772598b5

View File

@ -1089,7 +1089,7 @@ freeDevice(InputInfoPtr *list, InputInfoPtr pInfo)
/** /**
* Append pInfo to the null-terminated list, allocating space as necessary. * Append pInfo to the null-terminated list, allocating space as necessary.
* pInfo is copied into the last element. * pInfo is used as the last element.
*/ */
static InputInfoPtr* static InputInfoPtr*
addDevice(InputInfoPtr *list, InputInfoPtr pInfo) addDevice(InputInfoPtr *list, InputInfoPtr pInfo)
@ -1103,8 +1103,7 @@ addDevice(InputInfoPtr *list, InputInfoPtr pInfo)
list = xnfrealloc(list, (count + 1) * sizeof(InputInfoPtr)); list = xnfrealloc(list, (count + 1) * sizeof(InputInfoPtr));
list[count] = NULL; list[count] = NULL;
list[count - 1] = xnfalloc(sizeof(InputInfoRec)); list[count - 1] = pInfo;
*list[count - 1] = *pInfo;
return list; return list;
} }
@ -1131,7 +1130,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
const char *pointerMsg = NULL, *keyboardMsg = NULL; const char *pointerMsg = NULL, *keyboardMsg = NULL;
InputInfoPtr *devs, /* iterator */ InputInfoPtr *devs, /* iterator */
indp; indp;
InputInfoRec Pointer = {}, Keyboard = {}; InputInfoPtr Pointer, Keyboard;
XF86ConfInputPtr confInput; XF86ConfInputPtr confInput;
XF86ConfInputRec defPtr, defKbd; XF86ConfInputRec defPtr, defKbd;
MessageType from = X_DEFAULT; MessageType from = X_DEFAULT;
@ -1235,18 +1234,20 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
/* Add the core pointer device to the layout, and set it to Core. */ /* Add the core pointer device to the layout, and set it to Core. */
if (foundPointer && confInput) { if (foundPointer && confInput) {
foundPointer = configInput(&Pointer, confInput, from); Pointer = xf86AllocateInput();
if (foundPointer) { if (Pointer)
Pointer.options = xf86addNewOption(Pointer.options, foundPointer = configInput(Pointer, confInput, from);
if (foundPointer) {
Pointer->options = xf86addNewOption(Pointer->options,
xnfstrdup("CorePointer"), "on"); xnfstrdup("CorePointer"), "on");
Pointer.fd = -1; servlayoutp->inputs = addDevice(servlayoutp->inputs, Pointer);
servlayoutp->inputs = addDevice(servlayoutp->inputs, &Pointer);
} }
} }
if (!foundPointer && xf86Info.forceInputDevices) { if (!foundPointer && xf86Info.forceInputDevices) {
/* This shouldn't happen. */ /* This shouldn't happen. */
xf86Msg(X_ERROR, "Cannot locate a core pointer device.\n"); xf86Msg(X_ERROR, "Cannot locate a core pointer device.\n");
xf86DeleteInput(Pointer, 0);
return FALSE; return FALSE;
} }
@ -1274,12 +1275,13 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
defPtr.inp_identifier = strdup("<default pointer>"); defPtr.inp_identifier = strdup("<default pointer>");
defPtr.inp_driver = strdup("mouse"); defPtr.inp_driver = strdup("mouse");
confInput = &defPtr; confInput = &defPtr;
foundPointer = configInput(&Pointer, confInput, from); Pointer = xf86AllocateInput();
if (foundPointer) { if (Pointer)
Pointer.options = xf86addNewOption(NULL, foundPointer = configInput(Pointer, confInput, from);
if (foundPointer) {
Pointer->options = xf86addNewOption(NULL,
xnfstrdup("AlwaysCore"), "on"); xnfstrdup("AlwaysCore"), "on");
Pointer.fd = -1; servlayoutp->inputs = addDevice(servlayoutp->inputs, Pointer);
servlayoutp->inputs = addDevice(servlayoutp->inputs, &Pointer);
} }
} }
@ -1356,18 +1358,20 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
/* Add the core keyboard device to the layout, and set it to Core. */ /* Add the core keyboard device to the layout, and set it to Core. */
if (foundKeyboard && confInput) { if (foundKeyboard && confInput) {
foundKeyboard = configInput(&Keyboard, confInput, from); Keyboard = xf86AllocateInput();
if (foundKeyboard) { if (Keyboard)
Keyboard.options = xf86addNewOption(Keyboard.options, foundKeyboard = configInput(Keyboard, confInput, from);
if (foundKeyboard) {
Keyboard->options = xf86addNewOption(Keyboard->options,
xnfstrdup("CoreKeyboard"), "on"); xnfstrdup("CoreKeyboard"), "on");
Keyboard.fd = -1; servlayoutp->inputs = addDevice(servlayoutp->inputs, Keyboard);
servlayoutp->inputs = addDevice(servlayoutp->inputs, &Keyboard);
} }
} }
if (!foundKeyboard && xf86Info.forceInputDevices) { if (!foundKeyboard && xf86Info.forceInputDevices) {
/* This shouldn't happen. */ /* This shouldn't happen. */
xf86Msg(X_ERROR, "Cannot locate a core keyboard device.\n"); xf86Msg(X_ERROR, "Cannot locate a core keyboard device.\n");
xf86DeleteInput(Keyboard, 0);
return FALSE; return FALSE;
} }