summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2010-06-01 13:03:31 +0200
committerCarlos Garnacho <carlosg@gnome.org>2010-06-02 01:10:22 +0200
commit67c75047fa126fced09dd7b59a84886ef0c6818c (patch)
tree8764ab9d1292f0d230055b6af241d530cc7c1c36
parent13a2905b2e14fe5982bc4c24afe3c75da27d45d1 (diff)
Do not require main device InputOptions copying.
-rw-r--r--src/evdev.c71
1 files changed, 23 insertions, 48 deletions
diff --git a/src/evdev.c b/src/evdev.c
index 0107da2..8f68115 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -3110,27 +3110,6 @@ EvdevSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
#endif
/* Duplicate xf86 options and convert them to InputOption */
-static InputOption *EvdevOptionDupConvert(pointer original)
-{
- InputOption *iopts = NULL, *new;
- InputInfoRec dummy;
-
-
- memset(&dummy, 0, sizeof(dummy));
- xf86CollectInputOptions(&dummy, NULL, original);
-
- while (dummy.options) {
- new = xcalloc(1, sizeof(InputOption));
-
- new->key = xf86OptionName(dummy.options);
- new->value = xf86OptionValue(dummy.options);
-
- new->next = iopts;
- iopts = new;
- dummy.options = xf86NextOption(dummy.options);
- }
- return iopts;
-}
static void EvdevFreeInputOpts(InputOption *opts)
{
InputOption *tmp = opts;
@@ -3143,17 +3122,22 @@ static void EvdevFreeInputOpts(InputOption *opts)
opts = tmp;
}
}
-static void EvdevReplaceOption(InputOption *opts, const char* key, char * value)
-{
- while (opts) {
- if (xf86NameCmp(opts->key, key) == 0) {
+/* Copied from xserver/config/config.c */
+static void
+add_option(InputOption **options, const char *key, const char *value)
+{
+ if (!value || *value == '\0')
+ return;
- xfree(opts->value);
- opts->value = strdup(value);
- }
- opts = opts->next;
- }
+ for (; *options; options = &(*options)->next)
+ ;
+ *options = xcalloc(sizeof(**options), 1);
+ if (!*options) /* Yeesh. */
+ return;
+ (*options)->key = xstrdup(key);
+ (*options)->value = xstrdup(value);
+ (*options)->next = NULL;
}
/**
@@ -3164,31 +3148,23 @@ static void EvdevReplaceOption(InputOption *opts, const char* key, char * value)
static InputInfoPtr
EvdevCreateSubDevice(InputInfoPtr pInfo, int id) {
InputInfoPtr pSubdev = NULL;
-
DeviceIntPtr dev = NULL; /* dummy */
InputOption *input_options = NULL;
char *name;
+ add_option (&input_options, "Type", "Object");
+ add_option (&input_options, "SendCoreEvents", "on");
+ add_option (&input_options, "driver",
+ xf86FindOptionValue (pInfo->options, "driver"));
- pInfo->options = xf86AddNewOption(pInfo->options, "Type", "core");
- pInfo->options = xf86AddNewOption(pInfo->options, "SendCoreEvents", "on");
-
- /* forcing the evdev driver if it was not correctly detected */
- pInfo->options = xf86AddNewOption(pInfo->options, "driver", "evdev");
- pInfo->options = xf86AddNewOption(pInfo->options, "name", pInfo->name);
+ name = xalloc((strlen(pInfo->name) + strlen(" subdev ") + 20) * sizeof(char)); /* 20 for adding the id */
+ sprintf(name, "%s subdev %d", pInfo->name, id);
- /* Create new device */
-
- input_options = EvdevOptionDupConvert(pInfo->options);
-
- EvdevReplaceOption(input_options, "Type", "Object");
-
- /* EvdevReplaceOption(input_options, "SendCoreEvents","off"); *//* FIXME: bug in xserver */
- name = xalloc((strlen(pInfo->name) + strlen(" subdev ") + 20)*sizeof(char)); /* 20 for adding the id */
- sprintf(name, "%s subdev %i", pInfo->name, id);
- EvdevReplaceOption(input_options, "name", name);
+ add_option (&input_options, "name", name);
+ xfree(name);
pCreatorInfo = pInfo;
+
NewInputDeviceRequest(input_options,
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 9
NULL,
@@ -3200,7 +3176,6 @@ EvdevCreateSubDevice(InputInfoPtr pInfo, int id) {
EvdevFreeInputOpts(input_options);
- xfree(name);
return pSubdev;
}