summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2011-10-31 14:33:08 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2011-11-02 08:41:19 +1000
commit7ccf3a75292d71104c976bf6afb389cccaac1a7d (patch)
treeb03890b1f5dcc4822204df1b36f5bebeb03f20dc
parente0193debf8f5a72b0a06977d5dea3365ad9cafbe (diff)
Deal with opaque input option types.
ABI 14 made the InputOption type opaque, move the existing code to ifdefs and use the new function calls otherwise. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com> Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
-rw-r--r--src/jstk_key.c53
1 files changed, 38 insertions, 15 deletions
diff --git a/src/jstk_key.c b/src/jstk_key.c
index e842941..a71275a 100644
--- a/src/jstk_key.c
+++ b/src/jstk_key.c
@@ -247,13 +247,46 @@ int jstkKeyboardPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
return Success;
}
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 14
+static InputOption*
+input_option_new(InputOption* list, char *key, char *value)
+{
+ InputOption *tmp;
+
+ tmp = calloc(1, sizeof(*tmp));
+ tmp->key = key;
+ tmp->value = value;
+ tmp->next = list;
+
+ return tmp;
+}
+
+static void
+input_option_free_list(InputOption **list)
+{
+ InputOption *iopts = *list;
+
+ while(iopts)
+ {
+ InputOption *tmp = iopts->next;
+ free(iopts->key);
+ free(iopts->value);
+ free(iopts);
+ iopts = tmp;
+ }
+
+ *list = NULL;
+}
+
+#endif
+
InputInfoPtr
jstkKeyboardHotplug(InputInfoPtr pInfo, int flags)
{
int rc;
char name[512] = {0};
InputAttributes *attrs = NULL;
- InputOption *iopts = NULL, *tmp;
+ InputOption *iopts = NULL;
DeviceIntPtr dev;
XF86OptionPtr opts;
@@ -266,12 +299,9 @@ jstkKeyboardHotplug(InputInfoPtr pInfo, int flags)
while(opts)
{
- tmp = calloc(1, sizeof(InputOption));
-
- tmp->key = xf86OptionName(opts);
- tmp->value = xf86OptionValue(opts);
- tmp->next = iopts;
- iopts = tmp;
+ iopts = input_option_new(iopts,
+ xf86OptionName(opts),
+ xf86OptionValue(opts));
opts = xf86NextOption(opts);
}
@@ -280,14 +310,7 @@ jstkKeyboardHotplug(InputInfoPtr pInfo, int flags)
rc = NewInputDeviceRequest(iopts, attrs, &dev);
- while(iopts)
- {
- tmp = iopts->next;
- free(iopts->key);
- free(iopts->value);
- free(iopts);
- iopts = tmp;
- }
+ input_option_free_list(&iopts);
FreeInputAttributes(attrs);