summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTiago Vignatti <tiagov@balalaika.(none)>2007-08-07 02:16:44 -0300
committerTiago Vignatti <tiagov@balalaika.(none)>2007-08-07 02:16:44 -0300
commit7a5eb3e96b74daaaeb6babf46b13d698280aa3f6 (patch)
treeacb096f2064e4abc9c8aa53fe107b7bb77db35b9
parent955d5f6c0d14fae63bfe7c4ab39ee0a708919479 (diff)
Let xkb options be passed through command line in kdrive servers. I start my
Xephyr using something like: ./hw/kdrive/ephyr/Xephyr :1 -fp /usr/share/fonts/X11/misc/ -mouse ephyr -keybd ephyr,,xkblayout=br,xkbmodel=abnt2
-rw-r--r--hw/kdrive/src/kdrive.h5
-rw-r--r--hw/kdrive/src/kinput.c113
2 files changed, 108 insertions, 10 deletions
diff --git a/hw/kdrive/src/kdrive.h b/hw/kdrive/src/kdrive.h
index 2ebde2203..21f953921 100644
--- a/hw/kdrive/src/kdrive.h
+++ b/hw/kdrive/src/kdrive.h
@@ -330,6 +330,11 @@ struct _KdKeyboardInfo {
int inputClass;
#ifdef XKB
XkbDescPtr xkb;
+ char *xkbRules;
+ char *xkbModel;
+ char *xkbLayout;
+ char *xkbVariant;
+ char *xkbOptions;
#endif
int LockLed;
diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index 8018befdc..b84e98964 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -792,7 +792,9 @@ KdKeyboardProc(DeviceIntPtr pDevice, int onoff)
if (!noXkbExtension) {
memset(&names, 0, sizeof(XkbComponentNamesRec));
- XkbSetRulesDflts ("base", "pc105", "us", NULL, NULL);
+ XkbSetRulesDflts (ki->xkbRules, ki->xkbModel, ki->xkbLayout,
+ ki->xkbVariant, ki->xkbOptions);
+
ret = XkbInitKeyboardDeviceStruct (pDevice,
&names,
&ki->keySyms,
@@ -961,6 +963,13 @@ KdNewKeyboard (void)
ki->bellDuration = 200;
ki->next = NULL;
ki->options = NULL;
+#ifdef XKB
+ ki->xkbRules = KdSaveString("base");
+ ki->xkbModel = KdSaveString("pc105");
+ ki->xkbLayout = KdSaveString("us");
+ ki->xkbVariant = NULL;
+ ki->xkbOptions = NULL;
+#endif
return ki;
}
@@ -1096,11 +1105,36 @@ KdRemovePointer (KdPointerInfo *pi)
KdFreePointer(pi);
}
+static void
+KdParseKbdOptions (KdKeyboardInfo *ki)
+{
+ InputOption *option = NULL;
+
+ for (option = ki->options; option; option = option->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
+ ErrorF("Kbd option key (%s) of value (%s) not assigned!\n",
+ option->key, option->value);
+ }
+}
+
KdKeyboardInfo *
KdParseKeyboard (char *arg)
{
char save[1024];
char delim;
+ InputOption *options = NULL, *newopt = NULL, **tmpo = NULL;
+ int i = 0;
KdKeyboardInfo *ki = NULL;
ki = KdNewKeyboard();
@@ -1143,11 +1177,75 @@ KdParseKeyboard (char *arg)
else
ki->driverPrivate = xstrdup(save);
- /* FIXME actually implement options */
+ if (delim != ',')
+ {
+ return ki;
+ }
+
+ arg = KdParseFindNext (arg, ",", save, &delim);
+
+ while (delim == ',')
+ {
+ arg = KdParseFindNext (arg, ",", save, &delim);
+
+ newopt = (InputOption *) xalloc(sizeof (InputOption));
+ if (!newopt)
+ {
+ KdFreeKeyboard(ki);
+ return NULL;
+ }
+ bzero(newopt, sizeof (InputOption));
+
+ for (tmpo = &options; *tmpo; tmpo = &(*tmpo)->next)
+ ; /* Hello, I'm here */
+ *tmpo = newopt;
+
+ if (strchr(save, '='))
+ {
+ i = (strchr(save, '=') - save);
+ newopt->key = (char *)xalloc(i);
+ strncpy(newopt->key, save, i);
+ newopt->key[i] = '\0';
+ newopt->value = xstrdup(strchr(save, '=') + 1);
+ }
+ else
+ {
+ newopt->key = xstrdup(save);
+ newopt->value = NULL;
+ }
+ newopt->next = NULL;
+ }
+
+ if (options)
+ {
+ ki->options = options;
+ KdParseKbdOptions(ki);
+ }
return ki;
}
+static void
+KdParsePointerOptions (KdPointerInfo *pi)
+{
+ InputOption *option = NULL;
+
+ for (option = pi->options; option; option = option->next)
+ {
+ if (!strcmp (option->key, "emulatemiddle"))
+ pi->emulateMiddleButton = TRUE;
+ else if (!strcmp (option->key, "noemulatemiddle"))
+ pi->emulateMiddleButton = FALSE;
+ else if (!strcmp (option->key, "transformcoord"))
+ pi->transformCoordinates = TRUE;
+ else if (!strcmp (option->key, "rawcoord"))
+ pi->transformCoordinates = FALSE;
+ else
+ ErrorF("Pointer option key (%s) of value (%s) not assigned!\n",
+ option->key, option->value);
+ }
+}
+
KdPointerInfo *
KdParsePointer (char *arg)
{
@@ -1214,14 +1312,6 @@ KdParsePointer (char *arg)
s++;
}
}
- else if (!strcmp (save, "emulatemiddle"))
- pi->emulateMiddleButton = TRUE;
- else if (!strcmp (save, "noemulatemiddle"))
- pi->emulateMiddleButton = FALSE;
- else if (!strcmp (save, "transformcoord"))
- pi->transformCoordinates = TRUE;
- else if (!strcmp (save, "rawcoord"))
- pi->transformCoordinates = FALSE;
else
{
newopt = (InputOption *) xalloc(sizeof (InputOption));
@@ -1255,7 +1345,10 @@ KdParsePointer (char *arg)
}
if (options)
+ {
pi->options = options;
+ KdParsePointerOptions(pi);
+ }
return pi;
}