[PATCH 11/19] xfree86: remove IDevRec, replace with InputInfoRec.
Tiago Vignatti
tiago.vignatti at nokia.com
Mon Sep 6 08:47:11 PDT 2010
On Mon, Sep 06, 2010 at 04:52:47AM +0200, ext Peter Hutterer wrote:
> This struct is superfluous, maintaining the same info as the InputInfoRec
> (with the exception of the driver name).
>
> This is a rather large commit with the majority of changes being a rename
> from the fields of the IDevRec (idev, commonOptions) to the InputInfoRec
> (pInfo, options).
>
> The actual changes affect the initialization process of the input device:
> In NewInputDeviceRequest, the InputInfoRec is now always allocated and just
> added to the internal list in xf86NewInputDevice() if the init process
> succeeded.
>
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> ---
> hw/xfree86/common/xf86Config.c | 74 +++++++++++-----------
> hw/xfree86/common/xf86Init.c | 2 +-
> hw/xfree86/common/xf86Option.c | 26 ++------
> hw/xfree86/common/xf86Xinput.c | 139 ++++++++++++++++++----------------------
> hw/xfree86/common/xf86Xinput.h | 10 ++-
> hw/xfree86/common/xf86str.h | 11 +--
> 6 files changed, 114 insertions(+), 148 deletions(-)
>
> diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
> index 5d69c22..0ebee9e 100644
> --- a/hw/xfree86/common/xf86Config.c
> +++ b/hw/xfree86/common/xf86Config.c
> @@ -135,7 +135,7 @@ static Bool configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen,
> static Bool configMonitor(MonPtr monitorp, XF86ConfMonitorPtr conf_monitor);
> static Bool configDevice(GDevPtr devicep, XF86ConfDevicePtr conf_device,
> Bool active);
> -static Bool configInput(IDevPtr inputp, XF86ConfInputPtr conf_input,
> +static Bool configInput(InputInfoPtr pInfo, XF86ConfInputPtr conf_input,
> MessageType from);
> static Bool configDisplay(DispPtr displayp, XF86ConfDisplayPtr conf_display);
> static Bool addDefaultModes(MonPtr monitorp);
> @@ -444,8 +444,8 @@ xf86InputDriverlistFromConfig(void)
> {
> int count = 0;
> char **modulearray;
> - IDevPtr* idp;
> -
> + InputInfoPtr *idp;
> +
> /*
> * make sure the config file has been parsed and that we have a
> * ModulePath set; if no ModulePath was given, use the default
> @@ -1110,12 +1110,12 @@ Bool xf86DRI2Enabled(void)
> static Bool
> checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
> {
> - IDevPtr corePointer = NULL, coreKeyboard = NULL;
> + InputInfoPtr corePointer = NULL, coreKeyboard = NULL;
> Bool foundPointer = FALSE, foundKeyboard = FALSE;
> const char *pointerMsg = NULL, *keyboardMsg = NULL;
> - IDevPtr *devs, /* iterator */
> + InputInfoPtr *devs, /* iterator */
> indp;
> - IDevRec Pointer, Keyboard;
> + InputInfoRec Pointer, Keyboard;
> XF86ConfInputPtr confInput;
> XF86ConfInputRec defPtr, defKbd;
> int count = 0;
> @@ -1131,26 +1131,26 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
> */
> for (devs = servlayoutp->inputs; devs && *devs; devs++) {
> indp = *devs;
> - if (indp->commonOptions &&
> - xf86CheckBoolOption(indp->commonOptions, "CorePointer", FALSE)) {
> + if (indp->options &&
> + xf86CheckBoolOption(indp->options, "CorePointer", FALSE)) {
> if (!corePointer) {
> corePointer = indp;
> } else {
> - xf86ReplaceBoolOption(indp->commonOptions, "CorePointer", FALSE);
> + xf86ReplaceBoolOption(indp->options, "CorePointer", FALSE);
> xf86Msg(X_WARNING, "Duplicate core pointer devices. "
> "Removing core pointer attribute from \"%s\"\n",
> - indp->identifier);
> + indp->name);
> }
> }
> - if (indp->commonOptions &&
> - xf86CheckBoolOption(indp->commonOptions, "CoreKeyboard", FALSE)) {
> + if (indp->options &&
> + xf86CheckBoolOption(indp->options, "CoreKeyboard", FALSE)) {
> if (!coreKeyboard) {
> coreKeyboard = indp;
> } else {
> - xf86ReplaceBoolOption(indp->commonOptions, "CoreKeyboard", FALSE);
> + xf86ReplaceBoolOption(indp->options, "CoreKeyboard", FALSE);
> xf86Msg(X_WARNING, "Duplicate core keyboard devices. "
> "Removing core keyboard attribute from \"%s\"\n",
> - indp->identifier);
> + indp->name);
> }
> }
> count++;
> @@ -1177,7 +1177,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
> if (*devs == corePointer)
> {
> free(*devs);
> - *devs = (IDevPtr)0x1; /* ensure we dont skip next loop*/
> + *devs = (InputInfoPtr)0x1; /* ensure we dont skip next loop*/
> break;
> }
> for (; devs && *devs; devs++)
> @@ -1244,10 +1244,10 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
> if (foundPointer) {
> count++;
> devs = xnfrealloc(servlayoutp->inputs,
> - (count + 1) * sizeof(IDevPtr));
> - devs[count - 1] = xnfalloc(sizeof(IDevRec));
> + (count + 1) * sizeof(InputInfoPtr));
> + devs[count - 1] = xnfalloc(sizeof(InputInfoRec));
> *devs[count - 1] = Pointer;
> - devs[count - 1]->commonOptions =
> + devs[count - 1]->options =
> xf86addNewOption(NULL, xnfstrdup("CorePointer"), NULL);
> devs[count] = NULL;
> servlayoutp->inputs = devs;
> @@ -1288,10 +1288,10 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
> if (foundPointer) {
> count++;
> devs = xnfrealloc(servlayoutp->inputs,
> - (count + 1) * sizeof(IDevPtr));
> - devs[count - 1] = xnfalloc(sizeof(IDevRec));
> + (count + 1) * sizeof(InputInfoPtr));
> + devs[count - 1] = xnfalloc(sizeof(InputInfoRec));
> *devs[count - 1] = Pointer;
> - devs[count - 1]->commonOptions =
> + devs[count - 1]->options =
> xf86addNewOption(NULL, xnfstrdup("AlwaysCore"), NULL);
> devs[count] = NULL;
> servlayoutp->inputs = devs;
> @@ -1319,7 +1319,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
> if (*devs == coreKeyboard)
> {
> free(*devs);
> - *devs = (IDevPtr)0x1; /* ensure we dont skip next loop */
> + *devs = (InputInfoPtr)0x1; /* ensure we dont skip next loop */
> break;
> }
> for (; devs && *devs; devs++)
> @@ -1384,10 +1384,10 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
> if (foundKeyboard) {
> count++;
> devs = xnfrealloc(servlayoutp->inputs,
> - (count + 1) * sizeof(IDevPtr));
> - devs[count - 1] = xnfalloc(sizeof(IDevRec));
> + (count + 1) * sizeof(InputInfoPtr));
> + devs[count - 1] = xnfalloc(sizeof(InputInfoRec));
> *devs[count - 1] = Keyboard;
> - devs[count - 1]->commonOptions =
> + devs[count - 1]->options =
> xf86addNewOption(NULL, xnfstrdup("CoreKeyboard"), NULL);
> devs[count] = NULL;
> servlayoutp->inputs = devs;
> @@ -1459,7 +1459,7 @@ static Bool
> configInputDevices(XF86ConfLayoutPtr layout, serverLayoutPtr servlayoutp)
> {
> XF86ConfInputrefPtr irp;
> - IDevPtr *indp;
> + InputInfoPtr *indp;
> int count = 0;
>
> /*
> @@ -1472,19 +1472,19 @@ configInputDevices(XF86ConfLayoutPtr layout, serverLayoutPtr servlayoutp)
> }
> DebugF("Found %d input devices in the layout section %s\n",
> count, layout->lay_identifier);
> - indp = xnfcalloc((count + 1), sizeof(IDevPtr));
> + indp = xnfcalloc((count + 1), sizeof(InputInfoPtr));
> indp[count] = NULL;
> irp = layout->lay_input_lst;
> count = 0;
> while (irp) {
> - indp[count] = xnfalloc(sizeof(IDevRec));
> + indp[count] = xnfalloc(sizeof(InputInfoRec));
> if (!configInput(indp[count], irp->iref_inputdev, X_CONFIG)) {
> while(count--)
> free(indp[count]);
> free(indp);
> return FALSE;
> }
> - indp[count]->commonOptions = irp->iref_option_lst;
> + indp[count]->options = irp->iref_option_lst;
> count++;
> irp = (XF86ConfInputrefPtr)irp->list.next;
> }
> @@ -1707,7 +1707,7 @@ configImpliedLayout(serverLayoutPtr servlayoutp, XF86ConfScreenPtr conf_screen,
> MessageType from;
> XF86ConfScreenPtr s;
> screenLayoutPtr slp;
> - IDevPtr *indp;
> + InputInfoPtr *indp;
> XF86ConfLayoutRec layout;
>
> if (!servlayoutp)
> @@ -1753,7 +1753,7 @@ configImpliedLayout(serverLayoutPtr servlayoutp, XF86ConfScreenPtr conf_screen,
> from = X_DEFAULT;
> } else {
> /* Set up an empty input device list, then look for some core devices. */
> - indp = xnfalloc(sizeof(IDevPtr));
> + indp = xnfalloc(sizeof(InputInfoPtr));
> *indp = NULL;
> servlayoutp->inputs = indp;
> }
> @@ -2300,12 +2300,12 @@ configExtensions(XF86ConfExtensionsPtr conf_ext)
> }
>
> static Bool
> -configInput(IDevPtr inputp, XF86ConfInputPtr conf_input, MessageType from)
> +configInput(InputInfoPtr inputp, XF86ConfInputPtr conf_input, MessageType from)
> {
> xf86Msg(from, "|-->Input Device \"%s\"\n", conf_input->inp_identifier);
> - inputp->identifier = conf_input->inp_identifier;
> + inputp->name = conf_input->inp_identifier;
> inputp->driver = conf_input->inp_driver;
> - inputp->commonOptions = conf_input->inp_option_lst;
> + inputp->options = conf_input->inp_option_lst;
> inputp->attrs = NULL;
>
> return TRUE;
> @@ -2359,7 +2359,7 @@ checkInput(serverLayoutPtr layout, Bool implicit_layout) {
> */
> if (xf86Info.allowEmptyInput && layout->inputs)
> {
> - IDevPtr *dev = layout->inputs;
> + InputInfoPtr *dev = layout->inputs;
> BOOL warned = FALSE;
>
> while(*dev)
> @@ -2368,7 +2368,7 @@ checkInput(serverLayoutPtr layout, Bool implicit_layout) {
> strcmp((*dev)->driver, "mouse") == 0 ||
> strcmp((*dev)->driver, "vmmouse") == 0)
> {
> - IDevPtr *current;
> + InputInfoPtr *current;
> if (!warned)
> {
> xf86Msg(X_WARNING, "AllowEmptyInput is on, devices using "
> @@ -2376,7 +2376,7 @@ checkInput(serverLayoutPtr layout, Bool implicit_layout) {
> warned = TRUE;
> }
>
> - xf86Msg(X_WARNING, "Disabling %s\n", (*dev)->identifier);
> + xf86Msg(X_WARNING, "Disabling %s\n", (*dev)->name);
>
> current = dev;
> free(*dev);
> diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
> index ca532ee..f93933d 100644
> --- a/hw/xfree86/common/xf86Init.c
> +++ b/hw/xfree86/common/xf86Init.c
> @@ -822,7 +822,7 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
> void
> InitInput(int argc, char **argv)
> {
> - IDevPtr* pDev;
> + InputInfoPtr* pDev;
> DeviceIntPtr dev;
>
> xf86Info.vtRequestsPending = FALSE;
> diff --git a/hw/xfree86/common/xf86Option.c b/hw/xfree86/common/xf86Option.c
> index 5920deb..7ca2fdd 100644
> --- a/hw/xfree86/common/xf86Option.c
> +++ b/hw/xfree86/common/xf86Option.c
> @@ -118,38 +118,22 @@ xf86CollectOptions(ScrnInfoPtr pScrn, pointer extraOpts)
> }
>
> /*
> - * xf86CollectInputOptions collects the options for an InputDevice.
> - * This function requires that the following has been initialised:
> - *
> - * pInfo->conf_idev
> - *
> - * The extraOpts parameter may optionally contain a list of additional options
> - * to include.
> - *
> - * The order of precedence for options is:
> - *
> - * extraOpts, pInfo->conf_idev->extraOptions,
> - * pInfo->conf_idev->commonOptions, defaultOpts
> + * xf86CollectInputOptions collects extra options for an InputDevice (other
> + * than those added by the config backend).
> + * The options are merged into the existing ones and thus take precedence
> + * over the others.
> */
>
> void
> xf86CollectInputOptions(InputInfoPtr pInfo, const char **defaultOpts)
> {
> - XF86OptionPtr tmp;
> - pInfo->options = NULL;
> if (defaultOpts) {
> - pInfo->options = xf86OptionListCreate(defaultOpts, -1, 0);
> - }
> - if (pInfo->conf_idev && pInfo->conf_idev->commonOptions) {
> - tmp = xf86optionListDup(pInfo->conf_idev->commonOptions);
> + XF86OptionPtr tmp =xf86optionListCreate(defaultOpts, -1, 0);
> if (pInfo->options)
> pInfo->options = xf86optionListMerge(pInfo->options, tmp);
> else
> pInfo->options = tmp;
> }
> - if (pInfo->conf_idev && pInfo->conf_idev->attrs) {
> - pInfo->attrs = pInfo->conf_idev->attrs;
> - }
> }
>
> /* Created for new XInput stuff -- essentially extensions to the parser */
> diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
> index 0aa9c42..e0211d9 100644
> --- a/hw/xfree86/common/xf86Xinput.c
> +++ b/hw/xfree86/common/xf86Xinput.c
> @@ -505,7 +505,7 @@ MatchAttrToken(const char *attr, struct list *patterns,
> * statements must match.
> */
> static Bool
> -InputClassMatches(const XF86ConfInputClassPtr iclass, const IDevPtr idev,
> +InputClassMatches(const XF86ConfInputClassPtr iclass, const InputInfoPtr idev,
> const InputAttributes *attrs)
> {
> /* MatchProduct substring */
> @@ -585,7 +585,7 @@ InputClassMatches(const XF86ConfInputClassPtr iclass, const IDevPtr idev,
> * well as any previous InputClass sections.
> */
> static int
> -MergeInputClasses(const IDevPtr idev, const InputAttributes *attrs)
> +MergeInputClasses(const InputInfoPtr idev, const InputAttributes *attrs)
> {
> XF86ConfInputClassPtr cl;
> XF86OptionPtr classopts;
> @@ -610,9 +610,8 @@ MergeInputClasses(const IDevPtr idev, const InputAttributes *attrs)
>
> /* Apply options to device with InputClass settings preferred. */
> xf86Msg(X_CONFIG, "%s: Applying InputClass \"%s\"\n",
> - idev->identifier, cl->identifier);
> - idev->commonOptions = xf86optionListMerge(idev->commonOptions,
> - classopts);
> + idev->name, cl->identifier);
> + idev->options = xf86optionListMerge(idev->options, classopts);
> }
>
> return Success;
> @@ -623,7 +622,7 @@ MergeInputClasses(const IDevPtr idev, const InputAttributes *attrs)
> * value of the last matching class and holler when returning TRUE.
> */
> static Bool
> -IgnoreInputClass(const IDevPtr idev, const InputAttributes *attrs)
> +IgnoreInputClass(const InputInfoPtr idev, const InputAttributes *attrs)
> {
> XF86ConfInputClassPtr cl;
> Bool ignore = FALSE;
> @@ -640,38 +639,43 @@ IgnoreInputClass(const IDevPtr idev, const InputAttributes *attrs)
>
> if (ignore)
> xf86Msg(X_CONFIG, "%s: Ignoring device from InputClass \"%s\"\n",
> - idev->identifier, ignore_class);
> + idev->name, ignore_class);
> return ignore;
> }
>
> -/* Allocate a new InputInfoRec and append it to the tail of xf86InputDevs. */
> static InputInfoPtr
> -xf86AllocateInput(InputDriverPtr drv, IDevPtr idev)
> +xf86AllocateInput(void)
> {
> - InputInfoPtr new, *prev = NULL;
> + InputInfoPtr pInfo;
>
> - if (!(new = calloc(sizeof(InputInfoRec), 1)))
> - return NULL;
> + pInfo = calloc(sizeof(*pInfo), 1);
> + if (!pInfo)
> + return NULL;
> +
> + pInfo->fd = -1;
> + pInfo->type_name = "UNKNOWN";
> +
> + return pInfo;
> +}
> +
> +/* Append InputInfoRec to the tail of xf86InputDevs. */
> +static void
> +xf86AddInput(InputDriverPtr drv, InputInfoPtr pInfo)
> +{
> + InputInfoPtr *prev = NULL;
>
> - new->drv = drv;
> + pInfo->drv = drv;
> drv->refCount++;
> - new->module = DuplicateModule(drv->module, NULL);
> + pInfo->module = DuplicateModule(drv->module, NULL);
>
> for (prev = &xf86InputDevs; *prev; prev = &(*prev)->next)
> ;
>
> - *prev = new;
> - new->next = NULL;
> -
> - new->fd = -1;
> - new->name = idev->identifier;
> - new->type_name = "UNKNOWN";
> - new->conf_idev = idev;
> -
> - xf86CollectInputOptions(new, (const char**)drv->default_options);
> - xf86ProcessCommonOptions(new, new->options);
> + *prev = pInfo;
> + pInfo->next = NULL;
>
> - return new;
> + xf86CollectInputOptions(pInfo, (const char**)drv->default_options);
> + xf86ProcessCommonOptions(pInfo, pInfo->options);
> }
>
> /*
> @@ -710,6 +714,10 @@ xf86DeleteInput(InputInfoPtr pInp, int flags)
> p->next = pInp->next;
> /* Else the entry wasn't in the xf86InputDevs list (ignore this). */
> }
> +
> + free(pInp->driver);
> + free(pInp->name);
> + xf86optionListFree(pInp->options);
> free(pInp);
> }
>
> @@ -744,21 +752,20 @@ xf86InputDevicePostInit(DeviceIntPtr dev) {
> * @return Success or an error code
> */
> _X_INTERNAL int
> -xf86NewInputDevice(IDevPtr idev, DeviceIntPtr *pdev, BOOL enable)
> +xf86NewInputDevice(InputInfoPtr pInfo, DeviceIntPtr *pdev, BOOL enable)
> {
> InputDriverPtr drv = NULL;
> - InputInfoPtr pInfo = NULL;
> DeviceIntPtr dev = NULL;
> int rval;
>
> /* Memory leak for every attached device if we don't
> * test if the module is already loaded first */
> - drv = xf86LookupInputDriver(idev->driver);
> + drv = xf86LookupInputDriver(pInfo->driver);
> if (!drv)
> - if (xf86LoadOneModule(idev->driver, NULL))
> - drv = xf86LookupInputDriver(idev->driver);
> + if (xf86LoadOneModule(pInfo->driver, NULL))
> + drv = xf86LookupInputDriver(pInfo->driver);
> if (!drv) {
> - xf86Msg(X_ERROR, "No input driver matching `%s'\n", idev->driver);
> + xf86Msg(X_ERROR, "No input driver matching `%s'\n", pInfo->driver);
> rval = BadName;
> goto unwind;
> }
> @@ -771,13 +778,12 @@ xf86NewInputDevice(IDevPtr idev, DeviceIntPtr *pdev, BOOL enable)
> goto unwind;
> }
>
> - if (!(pInfo = xf86AllocateInput(drv, idev)))
> - goto unwind;
> + xf86AddInput(drv, pInfo);
>
> rval = drv->PreInit(drv, pInfo, 0);
>
> if (rval != Success) {
> - xf86Msg(X_ERROR, "PreInit returned %d for \"%s\"\n", rval, idev->identifier);
> + xf86Msg(X_ERROR, "PreInit returned %d for \"%s\"\n", rval, pInfo->name);
> goto unwind;
> }
>
> @@ -790,7 +796,7 @@ xf86NewInputDevice(IDevPtr idev, DeviceIntPtr *pdev, BOOL enable)
> rval = ActivateDevice(dev, TRUE);
> if (rval != Success)
> {
> - xf86Msg(X_ERROR, "Couldn't init device \"%s\"\n", idev->identifier);
> + xf86Msg(X_ERROR, "Couldn't init device \"%s\"\n", pInfo->name);
> RemoveDevice(dev, TRUE);
> goto unwind;
> }
> @@ -798,7 +804,7 @@ xf86NewInputDevice(IDevPtr idev, DeviceIntPtr *pdev, BOOL enable)
> rval = xf86InputDevicePostInit(dev);
> if (rval != Success)
> {
> - xf86Msg(X_ERROR, "Couldn't post-init device \"%s\"\n", idev->identifier);
> + xf86Msg(X_ERROR, "Couldn't post-init device \"%s\"\n", pInfo->name);
> RemoveDevice(dev, TRUE);
> goto unwind;
> }
> @@ -809,7 +815,7 @@ xf86NewInputDevice(IDevPtr idev, DeviceIntPtr *pdev, BOOL enable)
> EnableDevice(dev, TRUE);
> if (!dev->enabled)
> {
> - xf86Msg(X_ERROR, "Couldn't init device \"%s\"\n", idev->identifier);
> + xf86Msg(X_ERROR, "Couldn't init device \"%s\"\n", pInfo->name);
> rval = BadMatch;
> goto unwind;
> }
> @@ -834,23 +840,23 @@ int
> NewInputDeviceRequest (InputOption *options, InputAttributes *attrs,
> DeviceIntPtr *pdev)
> {
> - IDevRec *idev = NULL;
> + InputInfoPtr pInfo = NULL;
> InputOption *option = NULL;
> int rval = Success;
> int is_auto = 0;
>
> - idev = calloc(sizeof(*idev), 1);
> - if (!idev)
> + pInfo = xf86AllocateInput();
> + if (!pInfo)
> return BadAlloc;
>
> for (option = options; option; option = option->next) {
> if (strcasecmp(option->key, "driver") == 0) {
> - if (idev->driver) {
> + if (pInfo->driver) {
> rval = BadRequest;
> goto unwind;
> }
> - idev->driver = xstrdup(option->value);
> - if (!idev->driver) {
> + pInfo->driver = xstrdup(option->value);
> + if (!pInfo->driver) {
> rval = BadAlloc;
> goto unwind;
> }
> @@ -858,12 +864,12 @@ NewInputDeviceRequest (InputOption *options, InputAttributes *attrs,
>
> if (strcasecmp(option->key, "name") == 0 ||
> strcasecmp(option->key, "identifier") == 0) {
> - if (idev->identifier) {
> + if (pInfo->name) {
> rval = BadRequest;
> goto unwind;
> }
> - idev->identifier = xstrdup(option->value);
> - if (!idev->identifier) {
> + pInfo->name = xstrdup(option->value);
> + if (!pInfo->name) {
> rval = BadAlloc;
> goto unwind;
> }
> @@ -883,7 +889,7 @@ NewInputDeviceRequest (InputOption *options, InputAttributes *attrs,
> for (option = options; option; option = option->next) {
> /* Steal option key/value strings from the provided list.
> * We need those strings, the InputOption list doesn't. */
> - idev->commonOptions = xf86addNewOption(idev->commonOptions,
> + pInfo->options = xf86addNewOption(pInfo->options,
> option->key, option->value);
> option->key = NULL;
> option->value = NULL;
> @@ -891,42 +897,39 @@ NewInputDeviceRequest (InputOption *options, InputAttributes *attrs,
>
> /* Apply InputClass settings */
> if (attrs) {
> - if (IgnoreInputClass(idev, attrs)) {
> + if (IgnoreInputClass(pInfo, attrs)) {
> rval = BadIDChoice;
> goto unwind;
> }
>
> - rval = MergeInputClasses(idev, attrs);
> + rval = MergeInputClasses(pInfo, attrs);
> if (rval != Success)
> goto unwind;
>
> - idev->attrs = DuplicateInputAttributes(attrs);
> + pInfo->attrs = DuplicateInputAttributes(attrs);
> }
>
> - if (!idev->driver || !idev->identifier) {
> + if (!pInfo->driver || !pInfo->name) {
> xf86Msg(X_INFO, "No input driver/identifier specified (ignoring)\n");
> rval = BadRequest;
> goto unwind;
> }
>
> - if (!idev->identifier) {
> + if (!pInfo->name) {
> xf86Msg(X_ERROR, "No device identifier specified (ignoring)\n");
> rval = BadMatch;
> goto unwind;
> }
>
> - rval = xf86NewInputDevice(idev, pdev,
> + rval = xf86NewInputDevice(pInfo, pdev,
> (!is_auto || (is_auto && xf86Info.autoEnableDevices)));
> - if (rval == Success)
> - return Success;
> +
> + return rval;
>
> unwind:
> if (is_auto && !xf86Info.autoAddDevices)
> xf86Msg(X_INFO, "AutoAddDevices is off - not adding device.\n");
> - free(idev->driver);
> - free(idev->identifier);
> - xf86optionListFree(idev->commonOptions);
> - free(idev);
> + xf86DeleteInput(pInfo, 0);
> return rval;
> }
>
> @@ -935,15 +938,10 @@ DeleteInputDeviceRequest(DeviceIntPtr pDev)
> {
> InputInfoPtr pInfo = (InputInfoPtr) pDev->public.devicePrivate;
> InputDriverPtr drv = NULL;
> - IDevRec *idev = NULL;
> - IDevPtr *it;
> Bool isMaster = IsMaster(pDev);
>
> if (pInfo) /* need to get these before RemoveDevice */
> - {
> drv = pInfo->drv;
> - idev = pInfo->conf_idev;
> - }
>
> OsBlockSignals();
> RemoveDevice(pDev, TRUE);
> @@ -954,19 +952,6 @@ DeleteInputDeviceRequest(DeviceIntPtr pDev)
> drv->UnInit(drv, pInfo, 0);
> else
> xf86DeleteInput(pInfo, 0);
> -
> - /* devices added by the config backend aren't in the config layout */
> - it = xf86ConfigLayout.inputs;
> - while(*it && *it != idev)
> - it++;
> -
> - if (!(*it)) /* end of list, not in the layout */
> - {
> - free(idev->driver);
> - free(idev->identifier);
> - xf86optionListFree(idev->commonOptions);
> - free(idev);
> - }
> }
> OsReleaseSignals();
> }
> diff --git a/hw/xfree86/common/xf86Xinput.h b/hw/xfree86/common/xf86Xinput.h
> index 9211810..a0791d1 100644
> --- a/hw/xfree86/common/xf86Xinput.h
> +++ b/hw/xfree86/common/xf86Xinput.h
> @@ -97,9 +97,11 @@ typedef struct _InputDriverRec {
>
> /* This is to input devices what the ScrnInfoRec is to screens. */
>
> -typedef struct _InputInfoRec {
> +struct _InputInfoRec {
> struct _InputInfoRec *next;
> char * name;
> + char * driver;
> +
> int flags;
>
> Bool (*device_control)(DeviceIntPtr device, int what);
> @@ -117,12 +119,12 @@ typedef struct _InputInfoRec {
> DeviceIntPtr dev;
> pointer private;
> char * type_name;
> - IDevPtr conf_idev;
> InputDriverPtr drv;
> pointer module;
> pointer options;
> InputAttributes *attrs;
> -} InputInfoRec, *InputInfoPtr;
> +};
> +typedef InputInfoRec *InputInfoPtr;
I guess this hunk is correct, but stills a bit weird in terms of readability.
Why you chose to typedef in this unusual way?
> /* xf86Globals.c */
> extern _X_EXPORT InputInfoPtr xf86InputDevs;
> @@ -163,7 +165,7 @@ extern _X_EXPORT void xf86RemoveEnabledDevice(InputInfoPtr pInfo);
> extern _X_EXPORT void xf86DisableDevice(DeviceIntPtr dev, Bool panic);
> extern _X_EXPORT void xf86EnableDevice(DeviceIntPtr dev);
> /* not exported */
> -int xf86NewInputDevice(IDevPtr idev, DeviceIntPtr *pdev, BOOL is_auto);
> +int xf86NewInputDevice(InputInfoPtr pInfo, DeviceIntPtr *pdev, BOOL is_auto);
>
> /* xf86Helper.c */
> extern _X_EXPORT void xf86AddInputDriver(InputDriverPtr driver, pointer module, int flags);
> diff --git a/hw/xfree86/common/xf86str.h b/hw/xfree86/common/xf86str.h
> index 4659661..709c0f8 100644
> --- a/hw/xfree86/common/xf86str.h
> +++ b/hw/xfree86/common/xf86str.h
> @@ -402,13 +402,6 @@ typedef struct {
> } GDevRec, *GDevPtr;
>
> typedef struct {
> - char * identifier;
> - char * driver;
> - pointer commonOptions;
> - InputAttributes *attrs;
> -} IDevRec, *IDevPtr;
> -
> -typedef struct {
> int frameX0;
> int frameY0;
> int virtualX;
> @@ -477,11 +470,13 @@ typedef struct _screenlayoutrec {
> confScreenPtr refscreen;
> } screenLayoutRec, *screenLayoutPtr;
>
> +typedef struct _InputInfoRec InputInfoRec;
> +
> typedef struct _serverlayoutrec {
> char * id;
> screenLayoutPtr screens;
> GDevPtr inactives;
> - IDevPtr* inputs; /* NULL terminated */
> + InputInfoRec** inputs; /* NULL terminated */
> pointer options;
> } serverLayoutRec, *serverLayoutPtr;
>
> --
> 1.7.2.2
>
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel
Tiago
More information about the xorg-devel
mailing list