[patch] [RFC] HAL option handling.
Zephaniah E. Hull
warp at aehallh.com
Thu Aug 23 00:55:10 PDT 2007
Below is a patch which does some shuffling and adds a somewhat
controversial feature.
The shuffling is to move the HAL option handling to it's own function,
and to make us check for the XKB options for all input devices.
The controversial bit is that it also adds the input.x11_option.foo
namespace.
The argument against this is that we don't want people treating HAL's
FDI files as an XML xorg.conf replacement, and that we should be having
general device information in HAL instead of specific bits of driver
and device specific configuration.
The counter argument is simple. The server simply can't know enough
about future drivers and devices to reasonably provide input.xkb.foo
like options for every single type of device out there, especially not
ones that we don't know about yet.
Making it possible for distributions to ship FDI files that automaticly
configure various commonish devices that the drivers don't get quite
right by default simply makes sense, and restricting the options to
those the server knows about ahead of time is going to cause problems.
Yes, ideally, we want a solution which is nicely driver agnostic, but it
also needs to be more extensible then a fixed compiled-in mapping.
Alternative suggestions would be welcome.
Zephaniah E. Hull.
diff --git a/config/hal.c b/config/hal.c
index d7835e6..999c93d 100644
--- a/config/hal.c
+++ b/config/hal.c
@@ -149,12 +149,62 @@ get_prop_string_array(LibHalContext *hal_ctx, const char *udi, const char *prop)
}
static void
+handle_device_options (LibHalContext *hal_ctx, const char *udi, InputOption **options)
+{
+ DBusError error;
+ char *option;
+ const char *key, *value;
+ LibHalPropertySet *props;
+ LibHalPropertySetIterator it;
+ int type;
+
+ dbus_error_init(&error);
+
+#define handle_option(hname, xname, func) \
+ option = func (hal_ctx, udi, hname); \
+ if (option) { \
+ add_option (options, xname, option); \
+ xfree (option); \
+ }
+
+ /*
+ * The XKB options are special.
+ */
+ handle_option ("input.xkb.rules", "xkb_rules", get_prop_string);
+ handle_option ("input.xkb.model", "xkb_model", get_prop_string);
+ handle_option ("input.xkb.layout", "xkb_layout", get_prop_string);
+ handle_option ("input.xkb.variant", "xkb_variant", get_prop_string);
+ handle_option ("input.xkb.options", "xkb_options", get_prop_string_array);
+
+#undef handle_option
+ option = NULL;
+
+ props = libhal_device_get_all_properties (hal_ctx, udi, &error);
+ for (libhal_psi_init (&it, props); libhal_psi_has_more (&it); libhal_psi_next (&it)) {
+ type = libhal_psi_get_type (&it);
+ if (type != LIBHAL_PROPERTY_TYPE_STRING)
+ continue;
+
+ key = libhal_psi_get_key (&it);
+ if (strncasecmp (key, "input.x11_option.", 17))
+ continue;
+ key = strrchr(key, '.') + 1;
+ if (!*key)
+ continue;
+
+ value = libhal_psi_get_string (&it);
+ add_option (options, key, value);
+ }
+ libhal_free_property_set (props);
+ dbus_error_free(&error);
+}
+
+static void
device_added(LibHalContext *hal_ctx, const char *udi)
{
char **props;
- char *path = NULL, *driver = NULL, *name = NULL, *xkb_rules = NULL;
- char *xkb_model = NULL, *xkb_layout = NULL, *xkb_variant = NULL;
- char *xkb_options = NULL, *config_info = NULL;
+ char *path = NULL, *driver = NULL, *name = NULL;
+ char *config_info = NULL;
InputOption *options = NULL;
DeviceIntPtr dev;
DBusError error;
@@ -195,14 +245,6 @@ device_added(LibHalContext *hal_ctx, const char *udi)
if (!name)
name = xstrdup("(unnamed)");
- if (type & TYPE_KEYS) {
- xkb_rules = get_prop_string(hal_ctx, udi, "input.xkb.rules");
- xkb_model = get_prop_string(hal_ctx, udi, "input.xkb.model");
- xkb_layout = get_prop_string(hal_ctx, udi, "input.xkb.layout");
- xkb_variant = get_prop_string(hal_ctx, udi, "input.xkb.variant");
- xkb_options = get_prop_string_array(hal_ctx, udi, "input.xkb.options");
- }
-
options = xcalloc(sizeof(*options), 1);
options->key = xstrdup("_source");
options->value = xstrdup("server/hal");
@@ -219,17 +261,10 @@ device_added(LibHalContext *hal_ctx, const char *udi)
goto unwind;
sprintf(config_info, "hal:%s", udi);
- if (xkb_model)
- add_option(&options, "xkb_model", xkb_model);
- if (xkb_layout)
- add_option(&options, "xkb_layout", xkb_layout);
- if (xkb_variant)
- add_option(&options, "xkb_variant", xkb_variant);
- if (xkb_options)
- add_option(&options, "xkb_options", xkb_options);
+ handle_device_options (hal_ctx, udi, &options);
if (NewInputDeviceRequest(options, &dev) != Success) {
- DebugF("[config/hal] NewInputDeviceRequest failed\n");
+ ErrorF("[config/hal] NewInputDeviceRequest failed\n");
goto unwind;
}
@@ -243,14 +278,6 @@ unwind:
xfree(driver);
if (name)
xfree(name);
- if (xkb_rules)
- xfree(xkb_rules);
- if (xkb_model)
- xfree(xkb_model);
- if (xkb_layout)
- xfree(xkb_layout);
- if (xkb_options)
- xfree(xkb_options);
if (config_info)
xfree(config_info);
--
1024D/E65A7801 Zephaniah E. Hull <warp at aehallh.com>
92ED 94E4 B1E6 3624 226D 5727 4453 008B E65A 7801
CCs of replies from mailing lists are requested.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.x.org/archives/xorg/attachments/20070823/2b1bc7fa/attachment.pgp>
More information about the xorg
mailing list