aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/kdrive/src
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-10-27 08:37:52 +0200
committermarha <marha@users.sourceforge.net>2011-10-27 08:37:52 +0200
commit2a9be4af293f20fa33cc34fbc3b72e2235d91090 (patch)
treed41608bda1d56be1aa96857dee20e988b53760a3 /xorg-server/hw/kdrive/src
parent9d53da0fbb9ae6df9a38ad40df4f53cd28287235 (diff)
parentd662d461634660f5c0f3998b5eb7d7ed3bd5a25f (diff)
downloadvcxsrv-2a9be4af293f20fa33cc34fbc3b72e2235d91090.tar.gz
vcxsrv-2a9be4af293f20fa33cc34fbc3b72e2235d91090.tar.bz2
vcxsrv-2a9be4af293f20fa33cc34fbc3b72e2235d91090.zip
Merge remote-tracking branch 'origin/released'
Diffstat (limited to 'xorg-server/hw/kdrive/src')
-rw-r--r--xorg-server/hw/kdrive/src/kinput.c139
1 files changed, 79 insertions, 60 deletions
diff --git a/xorg-server/hw/kdrive/src/kinput.c b/xorg-server/hw/kdrive/src/kinput.c
index 3d87996be..27e33043f 100644
--- a/xorg-server/hw/kdrive/src/kinput.c
+++ b/xorg-server/hw/kdrive/src/kinput.c
@@ -49,6 +49,7 @@
#include "eventstr.h"
#include "xserver-properties.h"
#include "inpututils.h"
+#include "optionstr.h"
#define AtomFromName(x) MakeAtom(x, strlen(x), 1)
@@ -364,7 +365,7 @@ KdEnableInput (void)
}
static KdKeyboardDriver *
-KdFindKeyboardDriver (char *name)
+KdFindKeyboardDriver (const char *name)
{
KdKeyboardDriver *ret;
@@ -381,7 +382,7 @@ KdFindKeyboardDriver (char *name)
}
static KdPointerDriver *
-KdFindPointerDriver (char *name)
+KdFindPointerDriver (const char *name)
{
KdPointerDriver *ret;
@@ -1063,33 +1064,39 @@ KdRemovePointer (KdPointerInfo *pi)
static Bool
KdGetOptions (InputOption **options, char *string)
{
- InputOption *newopt = NULL, **tmpo = NULL;
+ InputOption *newopt = NULL;
+ char *key = NULL,
+ *value = NULL;
int tam_key = 0;
- newopt = calloc(1, sizeof (InputOption));
- if (!newopt)
- return FALSE;
-
- for (tmpo = options; *tmpo; tmpo = &(*tmpo)->next)
- ; /* Hello, I'm here */
- *tmpo = newopt;
-
if (strchr(string, '='))
{
tam_key = (strchr(string, '=') - string);
- newopt->key = (char *)malloc(tam_key);
- strncpy(newopt->key, string, tam_key);
- newopt->key[tam_key] = '\0';
- newopt->value = strdup(strchr(string, '=') + 1);
+ key = malloc(tam_key + 1);
+ if (!key)
+ goto out;
+
+ strncpy(key, string, tam_key);
+ key[tam_key] = '\0';
+ value = strdup(strchr(string, '=') + 1);
+ if (!value)
+ goto out;
}
else
{
- newopt->key = strdup(string);
- newopt->value = NULL;
+ key = strdup(string);
+ value = NULL;
}
- newopt->next = NULL;
- return TRUE;
+ newopt = input_option_new(*options, key, value);
+ if (newopt)
+ *options = newopt;
+
+out:
+ free(key);
+ free(value);
+
+ return (newopt != NULL);
}
static void
@@ -1097,23 +1104,26 @@ KdParseKbdOptions (KdKeyboardInfo *ki)
{
InputOption *option = NULL;
- for (option = ki->options; option; option = option->next)
+ nt_list_for_each_entry(option, ki->options, list.next)
{
- if (strcasecmp(option->key, "XkbRules") == 0)
- ki->xkbRules = option->value;
- else if (strcasecmp(option->key, "XkbModel") == 0)
- ki->xkbModel = option->value;
- else if (strcasecmp(option->key, "XkbLayout") == 0)
- ki->xkbLayout = option->value;
- else if (strcasecmp(option->key, "XkbVariant") == 0)
- ki->xkbVariant = option->value;
- else if (strcasecmp(option->key, "XkbOptions") == 0)
- ki->xkbOptions = option->value;
- else if (!strcasecmp (option->key, "device"))
- ki->path = strdup(option->value);
+ const char *key = input_option_get_key(option);
+ const char *value = input_option_get_value(option);
+
+ if (strcasecmp(key, "XkbRules") == 0)
+ ki->xkbRules = strdup(value);
+ else if (strcasecmp(key, "XkbModel") == 0)
+ ki->xkbModel = strdup(value);
+ else if (strcasecmp(key, "XkbLayout") == 0)
+ ki->xkbLayout = strdup(value);
+ else if (strcasecmp(key, "XkbVariant") == 0)
+ ki->xkbVariant = strdup(value);
+ else if (strcasecmp(key, "XkbOptions") == 0)
+ ki->xkbOptions = strdup(value);
+ else if (!strcasecmp (key, "device"))
+ ki->path = strdup(value);
else
ErrorF("Kbd option key (%s) of value (%s) not assigned!\n",
- option->key, option->value);
+ key, value);
}
}
@@ -1194,23 +1204,26 @@ KdParsePointerOptions (KdPointerInfo *pi)
{
InputOption *option = NULL;
- for (option = pi->options; option; option = option->next)
+ nt_list_for_each_entry(option, pi->options, list.next)
{
- if (!strcmp (option->key, "emulatemiddle"))
+ const char *key = input_option_get_key(option);
+ const char *value = input_option_get_value(option);
+
+ if (!strcmp (key, "emulatemiddle"))
pi->emulateMiddleButton = TRUE;
- else if (!strcmp (option->key, "noemulatemiddle"))
+ else if (!strcmp (key, "noemulatemiddle"))
pi->emulateMiddleButton = FALSE;
- else if (!strcmp (option->key, "transformcoord"))
+ else if (!strcmp (key, "transformcoord"))
pi->transformCoordinates = TRUE;
- else if (!strcmp (option->key, "rawcoord"))
+ else if (!strcmp (key, "rawcoord"))
pi->transformCoordinates = FALSE;
- else if (!strcasecmp (option->key, "device"))
- pi->path = strdup(option->value);
- else if (!strcasecmp (option->key, "protocol"))
- pi->protocol = strdup(option->value);
+ else if (!strcasecmp (key, "device"))
+ pi->path = strdup(value);
+ else if (!strcasecmp (key, "protocol"))
+ pi->protocol = strdup(value);
else
ErrorF("Pointer option key (%s) of value (%s) not assigned!\n",
- option->key, option->value);
+ key, value);
}
}
@@ -2241,14 +2254,17 @@ NewInputDeviceRequest(InputOption *options, InputAttributes *attrs,
KdPointerInfo *pi = NULL;
KdKeyboardInfo *ki = NULL;
- for (option = options; option; option = option->next) {
- if (strcmp(option->key, "type") == 0) {
- if (strcmp(option->value, "pointer") == 0) {
+ nt_list_for_each_entry(option, options, list.next) {
+ const char *key = input_option_get_key(option);
+ const char *value = input_option_get_value(option);
+
+ if (strcmp(key, "type") == 0) {
+ if (strcmp(value, "pointer") == 0) {
pi = KdNewPointer();
if (!pi)
return BadAlloc;
}
- else if (strcmp(option->value, "keyboard") == 0) {
+ else if (strcmp(value, "keyboard") == 0) {
ki = KdNewKeyboard();
if (!ki)
return BadAlloc;
@@ -2259,16 +2275,16 @@ NewInputDeviceRequest(InputOption *options, InputAttributes *attrs,
}
}
#ifdef CONFIG_HAL
- else if (strcmp(option->key, "_source") == 0 &&
- strcmp(option->value, "server/hal") == 0)
+ else if (strcmp(key, "_source") == 0 &&
+ strcmp(value, "server/hal") == 0)
{
ErrorF("Ignoring device from HAL.\n");
return BadValue;
}
#endif
#ifdef CONFIG_UDEV
- else if (strcmp(option->key, "_source") == 0 &&
- strcmp(option->value, "server/udev") == 0)
+ else if (strcmp(key, "_source") == 0 &&
+ strcmp(value, "server/udev") == 0)
{
ErrorF("Ignoring device from udev.\n");
return BadValue;
@@ -2283,16 +2299,19 @@ NewInputDeviceRequest(InputOption *options, InputAttributes *attrs,
/* FIXME: change this code below to use KdParseKbdOptions and
* KdParsePointerOptions */
- for (option = options; option; option = option->next) {
- if (strcmp(option->key, "device") == 0) {
- if (pi && option->value)
- pi->path = strdup(option->value);
- else if (ki && option->value)
- ki->path = strdup(option->value);
+ nt_list_for_each_entry(option, options, list.next) {
+ const char *key = input_option_get_key(option);
+ const char *value = input_option_get_value(option);
+
+ if (strcmp(key, "device") == 0) {
+ if (pi && value)
+ pi->path = strdup(value);
+ else if (ki && value)
+ ki->path = strdup(value);
}
- else if (strcmp(option->key, "driver") == 0) {
+ else if (strcmp(key, "driver") == 0) {
if (pi) {
- pi->driver = KdFindPointerDriver(option->value);
+ pi->driver = KdFindPointerDriver(value);
if (!pi->driver) {
ErrorF("couldn't find driver!\n");
KdFreePointer(pi);
@@ -2301,7 +2320,7 @@ NewInputDeviceRequest(InputOption *options, InputAttributes *attrs,
pi->options = options;
}
else if (ki) {
- ki->driver = KdFindKeyboardDriver(option->value);
+ ki->driver = KdFindKeyboardDriver(value);
if (!ki->driver) {
ErrorF("couldn't find driver!\n");
KdFreeKeyboard(ki);