xserver: Branch 'mpx' - 3 commits
Peter Hutterer
whot at kemper.freedesktop.org
Thu May 8 17:08:22 PDT 2008
config/hal.c | 141 +++++++++++++++++++++++++++++++++++++++++----------
config/x11-input.fdi | 16 ++---
2 files changed, 123 insertions(+), 34 deletions(-)
New commits:
commit fc35d1e3be201e3821413bb2eeb8d43e1e56ba17
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date: Thu May 8 16:58:31 2008 +0930
config: override xkb_{r,m,l,v} with Xkb{r,m,l,v} if the latter is set.
The HAL spec says that input.xkb.{rmlv}* can be sent, but if the user
specifies a X-specific {rmlv}, then this is overridden through the use of
input.x11_options.Xkb{RMLV}.
However, the way how the server parses options--by ignoring capitalisation,
underscores and spaces--the HAL and the x11_options would override each other.
So we simply filter the options, letting Xkb{RMLV} override xkb_{rmlv} and
only actually add them to the device after parsing _all_ options.
* rmlv ... rules, model, layout, variant
See Bug 13037 <http://bugs.freedesktop.org/show_bug.cgi?id=13037>
diff --git a/config/hal.c b/config/hal.c
index 7794d8e..67ffa03 100644
--- a/config/hal.c
+++ b/config/hal.c
@@ -48,6 +48,15 @@ struct config_hal_info {
LibHalContext *hal_ctx;
};
+/* Used for special handling of xkb options. */
+struct xkb_options {
+ char* layout;
+ char* model;
+ char* rules;
+ char* variant;
+};
+
+
static void
remove_device(DeviceIntPtr dev)
{
@@ -164,10 +173,11 @@ device_added(LibHalContext *hal_ctx, const char *udi)
InputOption *options = NULL, *tmpo = NULL;
DeviceIntPtr dev;
DBusError error;
+ struct xkb_options xkb_opts = {0};
LibHalPropertySet *set = NULL;
LibHalPropertySetIterator set_iter;
- char *psi_key = NULL, *tmp_val, *tmp_key;
+ char *psi_key = NULL, *tmp_val;
dbus_error_init(&error);
@@ -241,27 +251,71 @@ device_added(LibHalContext *hal_ctx, const char *udi)
tmp_val = get_prop_string(hal_ctx, udi, psi_key);
if (tmp_val){
- add_option(&options, psi_key + sizeof(LIBHAL_PROP_KEY)-1, tmp_val);
- xfree(tmp_val);
+ char* tmp;
+
+ /* xkb needs special handling. HAL specs include
+ * input.xkb.xyz options, but the x11-input.fdi specifies
+ * input.x11_options.Xkbxyz options. By default, we use
+ * the former, unless the specific X11 ones are specified.
+ * Since we can't predict the order in which the keys
+ * arrive, we need to store them.
+ */
+ if ((tmp = strcasestr(psi_key, "xkb")))
+ {
+ if (!strcasecmp(&tmp[3], "layout"))
+ {
+ if (xkb_opts.layout)
+ xfree(xkb_opts.layout);
+ xkb_opts.layout = strdup(tmp_val);
+ } else if (!strcasecmp(&tmp[3], "model"))
+ {
+ if (xkb_opts.model)
+ xfree(xkb_opts.model);
+ xkb_opts.model = strdup(tmp_val);
+ } else if (!strcasecmp(&tmp[3], "rules"))
+ {
+ if (xkb_opts.rules)
+ xfree(xkb_opts.rules);
+ xkb_opts.rules = strdup(tmp_val);
+ } else if (!strcasecmp(&tmp[3], "variant"))
+ {
+ if (xkb_opts.variant)
+ xfree(xkb_opts.variant);
+ xkb_opts.variant = strdup(tmp_val);
+ }
+ } else
+ {
+ /* all others */
+ add_option(&options, psi_key + sizeof(LIBHAL_PROP_KEY)-1, tmp_val);
+ xfree(tmp_val);
+ }
}
-
- /* evdev's XKB options... we should probably depreciate this usage */
} else if (!strncasecmp(psi_key, LIBHAL_XKB_PROP_KEY, sizeof(LIBHAL_XKB_PROP_KEY)-1)){
/* only support strings for all values */
tmp_val = get_prop_string(hal_ctx, udi, psi_key);
if (tmp_val){
- /* add "xkb_" + NULL */
- tmp_key = xalloc(strlen(psi_key) - ( sizeof(LIBHAL_XKB_PROP_KEY) - 1) + 5);
-
- if (!tmp_key){
- LogMessage(X_ERROR, "config/hal: couldn't allocate memory for option %s\n", psi_key);
- } else {
- sprintf(tmp_key, "xkb_%s", psi_key + sizeof(LIBHAL_XKB_PROP_KEY)-1);
- add_option(&options, tmp_key, tmp_val);
-
- xfree(tmp_key);
+ char* tmp;
+
+ tmp = &psi_key[sizeof(LIBHAL_XKB_PROP_KEY) - 1];
+
+ if (!strcasecmp(tmp, "layout"))
+ {
+ if (!xkb_opts.layout)
+ xkb_opts.layout = strdup(tmp_val);
+ } else if (!strcasecmp(tmp, "rules"))
+ {
+ if (!xkb_opts.rules)
+ xkb_opts.rules = strdup(tmp_val);
+ } else if (!strcasecmp(tmp, "variant"))
+ {
+ if (!xkb_opts.variant)
+ xkb_opts.variant = strdup(tmp_val);
+ } else if (!strcasecmp(tmp, "model"))
+ {
+ if (!xkb_opts.model)
+ xkb_opts.model = strdup(tmp_val);
}
xfree(tmp_val);
}
@@ -272,6 +326,17 @@ device_added(LibHalContext *hal_ctx, const char *udi)
libhal_psi_next(&set_iter);
}
+
+ /* Now add xkb options */
+ if (xkb_opts.layout)
+ add_option(&options, "xkb_layout", xkb_opts.layout);
+ if (xkb_opts.rules)
+ add_option(&options, "xkb_rules", xkb_opts.rules);
+ if (xkb_opts.variant)
+ add_option(&options, "xkb_variant", xkb_opts.variant);
+ if (xkb_opts.model)
+ add_option(&options, "xkb_model", xkb_opts.model);
+
/* this isn't an error, but how else do you output something that the user can see? */
LogMessage(X_INFO, "config/hal: Adding input device %s\n", name);
if (NewInputDeviceRequest(options, &dev) != Success) {
@@ -304,6 +369,15 @@ unwind:
xfree(tmpo);
}
+ if (xkb_opts.layout)
+ xfree(xkb_opts.layout);
+ if (xkb_opts.rules)
+ xfree(xkb_opts.rules);
+ if (xkb_opts.model)
+ xfree(xkb_opts.model);
+ if (xkb_opts.variant)
+ xfree(xkb_opts.variant);
+
dbus_error_free(&error);
return;
commit 1f54c05cf8a6b82e5fc6362f7f8e8fdc2444b9e8
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date: Thu May 8 14:05:56 2008 +0930
config: remove trailing whitespaces.
It makes my vim look ugly. Put "let c_space_errors=1" into your .vimrc.
diff --git a/config/hal.c b/config/hal.c
index f150646..7794d8e 100644
--- a/config/hal.c
+++ b/config/hal.c
@@ -119,7 +119,7 @@ get_prop_string(LibHalContext *hal_ctx, const char *udi, const char *name)
return ret;
}
-/* this function is no longer used... keep it here in case its needed in
+/* this function is no longer used... keep it here in case its needed in
* the future. */
#if 0
static char *
@@ -155,7 +155,7 @@ get_prop_string_array(LibHalContext *hal_ctx, const char *udi, const char *prop)
return ret;
}
-#endif
+#endif
static void
device_added(LibHalContext *hal_ctx, const char *udi)
@@ -164,12 +164,12 @@ device_added(LibHalContext *hal_ctx, const char *udi)
InputOption *options = NULL, *tmpo = NULL;
DeviceIntPtr dev;
DBusError error;
-
+
LibHalPropertySet *set = NULL;
LibHalPropertySetIterator set_iter;
char *psi_key = NULL, *tmp_val, *tmp_key;
-
-
+
+
dbus_error_init(&error);
driver = get_prop_string(hal_ctx, udi, "input.x11_driver");
@@ -178,13 +178,13 @@ device_added(LibHalContext *hal_ctx, const char *udi)
LogMessageVerb(X_INFO,7,"config/hal: no driver specified for device %s\n", udi);
goto unwind;
}
-
+
path = get_prop_string(hal_ctx, udi, "input.device");
if (!path) {
LogMessage(X_WARNING,"config/hal: no driver or path specified for %s\n", udi);
goto unwind;
}
-
+
name = get_prop_string(hal_ctx, udi, "info.product");
if (!name)
name = xstrdup("(unnamed)");
@@ -194,7 +194,7 @@ device_added(LibHalContext *hal_ctx, const char *udi)
LogMessage(X_ERROR, "config/hal: couldn't allocate space for input options!\n");
goto unwind;
}
-
+
options->key = xstrdup("_source");
options->value = xstrdup("server/hal");
if (!options->key || !options->value) {
@@ -202,14 +202,14 @@ device_added(LibHalContext *hal_ctx, const char *udi)
goto unwind;
}
- /* most drivers use device.. not path. evdev uses both however, but the
+ /* most drivers use device.. not path. evdev uses both however, but the
* path version isn't documented apparently. support both for now. */
add_option(&options, "path", path);
add_option(&options, "device", path);
-
+
add_option(&options, "driver", driver);
add_option(&options, "name", name);
-
+
config_info = xalloc(strlen(udi) + 5); /* "hal:" and NULL */
if (!config_info) {
LogMessage(X_ERROR, "config/hal: couldn't allocate name\n");
@@ -220,58 +220,58 @@ device_added(LibHalContext *hal_ctx, const char *udi)
/* ok, grab options from hal.. iterate through all properties
* and lets see if any of them are options that we can add */
set = libhal_device_get_all_properties(hal_ctx, udi, &error);
-
+
if (!set) {
LogMessage(X_ERROR, "config/hal: couldn't get property list for %s: %s (%s)\n",
udi, error.name, error.message);
goto unwind;
}
-
+
libhal_psi_init(&set_iter,set);
while (libhal_psi_has_more(&set_iter)) {
/* we are looking for supported keys.. extract and add to options */
- psi_key = libhal_psi_get_key(&set_iter);
-
+ psi_key = libhal_psi_get_key(&set_iter);
+
if (psi_key){
/* normal options first (input.x11_options.<propname>) */
if (!strncasecmp(psi_key, LIBHAL_PROP_KEY, sizeof(LIBHAL_PROP_KEY)-1)){
-
+
/* only support strings for all values */
tmp_val = get_prop_string(hal_ctx, udi, psi_key);
-
+
if (tmp_val){
add_option(&options, psi_key + sizeof(LIBHAL_PROP_KEY)-1, tmp_val);
xfree(tmp_val);
}
-
+
/* evdev's XKB options... we should probably depreciate this usage */
} else if (!strncasecmp(psi_key, LIBHAL_XKB_PROP_KEY, sizeof(LIBHAL_XKB_PROP_KEY)-1)){
-
+
/* only support strings for all values */
tmp_val = get_prop_string(hal_ctx, udi, psi_key);
-
+
if (tmp_val){
/* add "xkb_" + NULL */
tmp_key = xalloc(strlen(psi_key) - ( sizeof(LIBHAL_XKB_PROP_KEY) - 1) + 5);
-
+
if (!tmp_key){
LogMessage(X_ERROR, "config/hal: couldn't allocate memory for option %s\n", psi_key);
} else {
sprintf(tmp_key, "xkb_%s", psi_key + sizeof(LIBHAL_XKB_PROP_KEY)-1);
add_option(&options, tmp_key, tmp_val);
-
+
xfree(tmp_key);
}
xfree(tmp_val);
- }
+ }
}
}
-
+
/* psi_key doesn't need to be freed */
libhal_psi_next(&set_iter);
}
-
+
/* this isn't an error, but how else do you output something that the user can see? */
LogMessage(X_INFO, "config/hal: Adding input device %s\n", name);
if (NewInputDeviceRequest(options, &dev) != Success) {
@@ -413,7 +413,7 @@ config_hal_init(void)
/* verbose message */
LogMessageVerb(X_INFO,7,"config/hal: initialized");
-
+
return 1;
}
commit 1a314a1ef06222977e7ccb94331ce31c17534b2a
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date: Thu May 8 13:16:48 2008 +0930
Revert "config: deprecate (and ignore) the use of input.xkb.whatever options."
daniels:
"Hrm, I'd prefer to have input.xkb.{m,l,v,o} be the primary keys, and
have input.x11_options be a backup for that, rather than the former
being deprecated, for the reasons I listed earlier ..."
see http://bugs.freedesktop.org/show_bug.cgi?id=13037#c51
This reverts commit 26188875de1ccc84ac60bfb251e3ec43de2b9e22.
diff --git a/config/hal.c b/config/hal.c
index 05a02cc..f150646 100644
--- a/config/hal.c
+++ b/config/hal.c
@@ -167,7 +167,7 @@ device_added(LibHalContext *hal_ctx, const char *udi)
LibHalPropertySet *set = NULL;
LibHalPropertySetIterator set_iter;
- char *psi_key = NULL, *tmp_val;
+ char *psi_key = NULL, *tmp_val, *tmp_key;
dbus_error_init(&error);
@@ -244,10 +244,27 @@ device_added(LibHalContext *hal_ctx, const char *udi)
add_option(&options, psi_key + sizeof(LIBHAL_PROP_KEY)-1, tmp_val);
xfree(tmp_val);
}
- } /* don't accept input.xkb.whatever options anymore */
- else if (!strncasecmp(psi_key, LIBHAL_XKB_PROP_KEY, sizeof(LIBHAL_XKB_PROP_KEY)-1)){
- LogMessage(X_ERROR, "config/hal: Option '%s' is "
- "deprecated (ignoring).\n", psi_key);
+
+ /* evdev's XKB options... we should probably depreciate this usage */
+ } else if (!strncasecmp(psi_key, LIBHAL_XKB_PROP_KEY, sizeof(LIBHAL_XKB_PROP_KEY)-1)){
+
+ /* only support strings for all values */
+ tmp_val = get_prop_string(hal_ctx, udi, psi_key);
+
+ if (tmp_val){
+ /* add "xkb_" + NULL */
+ tmp_key = xalloc(strlen(psi_key) - ( sizeof(LIBHAL_XKB_PROP_KEY) - 1) + 5);
+
+ if (!tmp_key){
+ LogMessage(X_ERROR, "config/hal: couldn't allocate memory for option %s\n", psi_key);
+ } else {
+ sprintf(tmp_key, "xkb_%s", psi_key + sizeof(LIBHAL_XKB_PROP_KEY)-1);
+ add_option(&options, tmp_key, tmp_val);
+
+ xfree(tmp_key);
+ }
+ xfree(tmp_val);
+ }
}
}
diff --git a/config/x11-input.fdi b/config/x11-input.fdi
index 85d7a1f..f2e2d50 100644
--- a/config/x11-input.fdi
+++ b/config/x11-input.fdi
@@ -26,21 +26,19 @@
Do not specify "input.x11_options.Device" since "input.device"
will be used automatically.
-
- XKB configuration:
- "input.x11_options.XkbRules"
- "input.x11_options.XkbModel"
- "input.x11_options.XkbLayout"
- "input.x11_options.XkbVariant"
- "input.x11_options.XkbOptions"
-
- Legacy Keys (deprecated and ignored by the server):
+ Legacy Keys
"input.xkb.rules"
"input.xkb.model"
"input.xkb.layout"
"input.xkb.variant"
"input.xkb.options"
+ These keys are deprecated. Use these instead:
+ "input.x11_options.XkbRules"
+ "input.x11_options.XkbModel"
+ "input.x11_options.XkbLayout"
+ "input.x11_options.XkbVariant"
+ "input.x11_options.XkbOptions"
See the evdev documentation for more information.
More information about the xorg-commit
mailing list