diff options
author | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2012-06-10 13:21:33 +0000 |
---|---|---|
committer | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2012-06-10 13:21:33 +0000 |
commit | 171e929a08098b6c844887adc43879c7579dc15f (patch) | |
tree | 6b4d2e3bc20dbd4dc9a1f031416e66614c53dd21 /xserver/config | |
parent | 68781b09de2c95b87ea898c4ecf3018dfb4460d2 (diff) |
Update to xserver 1.12.2. tested by naddy@, krw@, mpi@.
Diffstat (limited to 'xserver/config')
-rw-r--r-- | xserver/config/Makefile.in | 14 | ||||
-rw-r--r-- | xserver/config/config-backends.h | 20 | ||||
-rw-r--r-- | xserver/config/config.c | 46 | ||||
-rw-r--r-- | xserver/config/dbus-core.c | 19 | ||||
-rw-r--r-- | xserver/config/dbus.c | 96 | ||||
-rw-r--r-- | xserver/config/hal.c | 295 | ||||
-rw-r--r-- | xserver/config/udev.c | 109 | ||||
-rw-r--r-- | xserver/config/wscons.c | 349 |
8 files changed, 454 insertions, 494 deletions
diff --git a/xserver/config/Makefile.in b/xserver/config/Makefile.in index af20b49bc..2baac3bd3 100644 --- a/xserver/config/Makefile.in +++ b/xserver/config/Makefile.in @@ -118,7 +118,6 @@ AGP_FALSE = @AGP_FALSE@ AGP_TRUE = @AGP_TRUE@ AIGLX_DRI_LOADER_FALSE = @AIGLX_DRI_LOADER_FALSE@ AIGLX_DRI_LOADER_TRUE = @AIGLX_DRI_LOADER_TRUE@ -ALLOCA = @ALLOCA@ ALPHA_VIDEO_FALSE = @ALPHA_VIDEO_FALSE@ ALPHA_VIDEO_TRUE = @ALPHA_VIDEO_TRUE@ AMDEP_FALSE = @AMDEP_FALSE@ @@ -137,6 +136,7 @@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ +BASE_CFLAGS = @BASE_CFLAGS@ BASE_FONT_PATH = @BASE_FONT_PATH@ BSD_APM_FALSE = @BSD_APM_FALSE@ BSD_APM_TRUE = @BSD_APM_TRUE@ @@ -344,8 +344,6 @@ LIB_MAN_DIR = @LIB_MAN_DIR@ LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ LINUX_ALPHA_FALSE = @LINUX_ALPHA_FALSE@ LINUX_ALPHA_TRUE = @LINUX_ALPHA_TRUE@ -LINUX_IA64_FALSE = @LINUX_IA64_FALSE@ -LINUX_IA64_TRUE = @LINUX_IA64_TRUE@ LIPO = @LIPO@ LNXACPI_FALSE = @LNXACPI_FALSE@ LNXACPI_TRUE = @LNXACPI_TRUE@ @@ -364,10 +362,6 @@ MISC_MAN_DIR = @MISC_MAN_DIR@ MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ MITSHM_FALSE = @MITSHM_FALSE@ MITSHM_TRUE = @MITSHM_TRUE@ -NEED_STRLCAT_FALSE = @NEED_STRLCAT_FALSE@ -NEED_STRLCAT_TRUE = @NEED_STRLCAT_TRUE@ -NEED_VSNPRINTF_FALSE = @NEED_VSNPRINTF_FALSE@ -NEED_VSNPRINTF_TRUE = @NEED_VSNPRINTF_TRUE@ NM = @NM@ NMEDIT = @NMEDIT@ OBJC = @OBJC@ @@ -511,18 +505,18 @@ XNEST_SYS_LIBS = @XNEST_SYS_LIBS@ XNEST_TRUE = @XNEST_TRUE@ XORG_BUS_BSDPCI_FALSE = @XORG_BUS_BSDPCI_FALSE@ XORG_BUS_BSDPCI_TRUE = @XORG_BUS_BSDPCI_TRUE@ -XORG_BUS_LINUXPCI_FALSE = @XORG_BUS_LINUXPCI_FALSE@ -XORG_BUS_LINUXPCI_TRUE = @XORG_BUS_LINUXPCI_TRUE@ +XORG_BUS_PCI_FALSE = @XORG_BUS_PCI_FALSE@ +XORG_BUS_PCI_TRUE = @XORG_BUS_PCI_TRUE@ XORG_BUS_SPARC_FALSE = @XORG_BUS_SPARC_FALSE@ XORG_BUS_SPARC_TRUE = @XORG_BUS_SPARC_TRUE@ XORG_CFLAGS = @XORG_CFLAGS@ XORG_FALSE = @XORG_FALSE@ XORG_INCS = @XORG_INCS@ XORG_LIBS = @XORG_LIBS@ +XORG_MALLOC_DEBUG_ENV = @XORG_MALLOC_DEBUG_ENV@ XORG_MAN_PAGE = @XORG_MAN_PAGE@ XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@ XORG_MODULES_LIBS = @XORG_MODULES_LIBS@ -XORG_OS = @XORG_OS@ XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ XORG_SGML_PATH = @XORG_SGML_PATH@ XORG_SYS_LIBS = @XORG_SYS_LIBS@ diff --git a/xserver/config/config-backends.h b/xserver/config/config-backends.h index 945cc1f40..e5622d51e 100644 --- a/xserver/config/config-backends.h +++ b/xserver/config/config-backends.h @@ -27,22 +27,22 @@ #include <dix-config.h> #endif #include "input.h" +#include "list.h" void remove_devices(const char *backend, const char *config_info); BOOL device_is_duplicate(const char *config_info); -void add_option(InputOption **options, const char *key, const char *value); #ifdef CONFIG_UDEV int config_udev_init(void); void config_udev_fini(void); #else -# ifdef CONFIG_NEED_DBUS +#ifdef CONFIG_NEED_DBUS #include <dbus/dbus.h> -typedef void (*config_dbus_core_connect_hook)(DBusConnection *connection, - void *data); -typedef void (*config_dbus_core_disconnect_hook)(void *data); +typedef void (*config_dbus_core_connect_hook) (DBusConnection * connection, + void *data); +typedef void (*config_dbus_core_disconnect_hook) (void *data); struct config_dbus_core_hook { config_dbus_core_connect_hook connect; @@ -56,17 +56,17 @@ int config_dbus_core_init(void); void config_dbus_core_fini(void); int config_dbus_core_add_hook(struct config_dbus_core_hook *hook); void config_dbus_core_remove_hook(struct config_dbus_core_hook *hook); -# endif +#endif -# ifdef CONFIG_DBUS_API +#ifdef CONFIG_DBUS_API int config_dbus_init(void); void config_dbus_fini(void); -# endif +#endif -# ifdef CONFIG_HAL +#ifdef CONFIG_HAL int config_hal_init(void); void config_hal_fini(void); -# endif +#endif #endif #ifdef CONFIG_WSCONS diff --git a/xserver/config/config.c b/xserver/config/config.c index 69bd6a137..2b96dbb74 100644 --- a/xserver/config/config.c +++ b/xserver/config/config.c @@ -40,21 +40,21 @@ config_init(void) ErrorF("[config] failed to initialise udev\n"); #elif defined(CONFIG_NEED_DBUS) if (config_dbus_core_init()) { -# ifdef CONFIG_DBUS_API - if (!config_dbus_init()) - ErrorF("[config] failed to initialise D-Bus API\n"); -# endif -# ifdef CONFIG_HAL +#ifdef CONFIG_DBUS_API + if (!config_dbus_init()) + ErrorF("[config] failed to initialise D-Bus API\n"); +#endif +#ifdef CONFIG_HAL if (!config_hal_init()) ErrorF("[config] failed to initialise HAL\n"); -# endif +#endif } else { - ErrorF("[config] failed to initialise D-Bus core\n"); + ErrorF("[config] failed to initialise D-Bus core\n"); } #elif defined(CONFIG_WSCONS) if (!config_wscons_init()) - ErrorF("[config] failed to initialise wscons\n"); + ErrorF("[config] failed to initialise wscons\n"); #endif } @@ -64,12 +64,12 @@ config_fini(void) #if defined(CONFIG_UDEV) config_udev_fini(); #elif defined(CONFIG_NEED_DBUS) -# ifdef CONFIG_HAL +#ifdef CONFIG_HAL config_hal_fini(); -# endif -# ifdef CONFIG_DBUS_API +#endif +#ifdef CONFIG_DBUS_API config_dbus_fini(); -# endif +#endif config_dbus_core_fini(); #elif defined(CONFIG_WSCONS) config_wscons_fini(); @@ -112,33 +112,15 @@ device_is_duplicate(const char *config_info) { DeviceIntPtr dev; - for (dev = inputInfo.devices; dev; dev = dev->next) - { + for (dev = inputInfo.devices; dev; dev = dev->next) { if (dev->config_info && (strcmp(dev->config_info, config_info) == 0)) return TRUE; } - for (dev = inputInfo.off_devices; dev; dev = dev->next) - { + for (dev = inputInfo.off_devices; dev; dev = dev->next) { if (dev->config_info && (strcmp(dev->config_info, config_info) == 0)) return TRUE; } return FALSE; } - -void -add_option(InputOption **options, const char *key, const char *value) -{ - if (!value || *value == '\0') - return; - - for (; *options; options = &(*options)->next) - ; - *options = calloc(sizeof(**options), 1); - if (!*options) /* Yeesh. */ - return; - (*options)->key = strdup(key); - (*options)->value = strdup(value); - (*options)->next = NULL; -} diff --git a/xserver/config/dbus-core.c b/xserver/config/dbus-core.c index 4c5e10f51..324258718 100644 --- a/xserver/config/dbus-core.c +++ b/xserver/config/dbus-core.c @@ -35,7 +35,7 @@ #include "os.h" /* How often to attempt reconnecting when we get booted off the bus. */ -#define RECONNECT_DELAY (10 * 1000) /* in ms */ +#define RECONNECT_DELAY (10 * 1000) /* in ms */ struct dbus_core_info { int fd; @@ -57,7 +57,8 @@ wakeup_handler(pointer data, int err, pointer read_mask) dbus_connection_read_write_dispatch(info->connection, 0); } while (info->connection && dbus_connection_get_is_connected(info->connection) && - dbus_connection_get_dispatch_status(info->connection) == DBUS_DISPATCH_DATA_REMAINS); + dbus_connection_get_dispatch_status(info->connection) == + DBUS_DISPATCH_DATA_REMAINS); } } @@ -105,13 +106,12 @@ teardown(void) * careful to ignore anything we don't want to deal with here. */ static DBusHandlerResult -message_filter(DBusConnection *connection, DBusMessage *message, void *data) +message_filter(DBusConnection * connection, DBusMessage * message, void *data) { /* If we get disconnected, then take everything down, and attempt to * reconnect immediately (assuming it's just a restart). The * connection isn't valid at this point, so throw it out immediately. */ - if (dbus_message_is_signal(message, DBUS_INTERFACE_LOCAL, - "Disconnected")) { + if (dbus_message_is_signal(message, DBUS_INTERFACE_LOCAL, "Disconnected")) { DebugF("[config/dbus-core] disconnected from bus\n"); bus_info.connection = NULL; teardown(); @@ -173,12 +173,12 @@ connect_to_bus(void) return 1; -err_fd: + err_fd: bus_info.fd = -1; -err_unref: + err_unref: dbus_connection_unref(bus_info.connection); bus_info.connection = NULL; -err_begin: + err_begin: dbus_error_free(&error); return 0; @@ -202,8 +202,7 @@ config_dbus_core_add_hook(struct config_dbus_core_hook *hook) { struct config_dbus_core_hook **prev; - for (prev = &bus_info.hooks; *prev; prev = &(*prev)->next) - ; + for (prev = &bus_info.hooks; *prev; prev = &(*prev)->next); hook->next = NULL; *prev = hook; diff --git a/xserver/config/dbus.c b/xserver/config/dbus.c index 34e3caade..99a1537e1 100644 --- a/xserver/config/dbus.c +++ b/xserver/config/dbus.c @@ -33,7 +33,7 @@ #include <X11/X.h> #include "config-backends.h" -#include "opaque.h" /* for 'display': there should be a better way. */ +#include "opaque.h" /* for 'display': there should be a better way. */ #include "input.h" #include "inputstr.h" @@ -65,11 +65,10 @@ reset_info(struct connection_info *info) } static int -add_device(DBusMessage *message, DBusMessage *reply, DBusError *error) +add_device(DBusMessage * message, DBusMessage * reply, DBusError * error) { DBusMessageIter iter, reply_iter, subiter; - InputOption *tmpo = NULL, *options = NULL; - char *tmp = NULL; + InputOption *input_options = NULL; int ret, err; DeviceIntPtr dev = NULL; @@ -80,15 +79,8 @@ add_device(DBusMessage *message, DBusMessage *reply, DBusError *error) MALFORMED_MESSAGE(); } - options = calloc(sizeof(*options), 1); - if (!options) { - ErrorF("[config/dbus] couldn't allocate option\n"); - return BadAlloc; - } - - options->key = strdup("_source"); - options->value = strdup("client/dbus"); - if (!options->key || !options->value) { + input_options = input_option_new(input_options, "_source", "client/dbus"); + if (!input_options) { ErrorF("[config/dbus] couldn't allocate first key/value pair\n"); ret = BadAlloc; goto unwind; @@ -96,36 +88,23 @@ add_device(DBusMessage *message, DBusMessage *reply, DBusError *error) /* signature should be [ss][ss]... */ while (dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_ARRAY) { - tmpo = calloc(sizeof(*tmpo), 1); - if (!tmpo) { - ErrorF("[config/dbus] couldn't allocate option\n"); - ret = BadAlloc; - goto unwind; - } - tmpo->next = options; - options = tmpo; + char *key, *value; dbus_message_iter_recurse(&iter, &subiter); if (dbus_message_iter_get_arg_type(&subiter) != DBUS_TYPE_STRING) MALFORMED_MESSAGE(); - dbus_message_iter_get_basic(&subiter, &tmp); - if (!tmp) + dbus_message_iter_get_basic(&subiter, &key); + if (!key) MALFORMED_MESSAGE(); /* The _ prefix refers to internal settings, and may not be given by * the client. */ - if (tmp[0] == '_') { + if (key[0] == '_') { ErrorF("[config/dbus] attempted subterfuge: option name %s given\n", - tmp); + key); MALFORMED_MESSAGE(); } - options->key = strdup(tmp); - if (!options->key) { - ErrorF("[config/dbus] couldn't duplicate key!\n"); - ret = BadAlloc; - goto unwind; - } if (!dbus_message_iter_has_next(&subiter)) MALFORMED_MESSAGE(); @@ -133,20 +112,16 @@ add_device(DBusMessage *message, DBusMessage *reply, DBusError *error) if (dbus_message_iter_get_arg_type(&subiter) != DBUS_TYPE_STRING) MALFORMED_MESSAGE(); - dbus_message_iter_get_basic(&subiter, &tmp); - if (!tmp) + dbus_message_iter_get_basic(&subiter, &value); + if (!value) MALFORMED_MESSAGE(); - options->value = strdup(tmp); - if (!options->value) { - ErrorF("[config/dbus] couldn't duplicate option!\n"); - ret = BadAlloc; - goto unwind; - } + + input_options = input_option_new(input_options, key, value); dbus_message_iter_next(&iter); } - ret = NewInputDeviceRequest(options, NULL, &dev); + ret = NewInputDeviceRequest(input_options, NULL, &dev); if (ret != Success) { DebugF("[config/dbus] NewInputDeviceRequest failed\n"); goto unwind; @@ -171,7 +146,7 @@ add_device(DBusMessage *message, DBusMessage *reply, DBusError *error) } } -unwind: + unwind: if (ret != Success) { if (dev) RemoveDevice(dev, TRUE); @@ -180,19 +155,13 @@ unwind: dbus_message_iter_append_basic(&reply_iter, DBUS_TYPE_INT32, &err); } - while (options) { - tmpo = options; - options = options->next; - free(tmpo->key); - free(tmpo->value); - free(tmpo); - } + input_option_free_list(&input_options); return ret; } static int -remove_device(DBusMessage *message, DBusMessage *reply, DBusError *error) +remove_device(DBusMessage * message, DBusMessage * reply, DBusError * error) { int deviceid, ret, err; DeviceIntPtr dev; @@ -228,7 +197,7 @@ remove_device(DBusMessage *message, DBusMessage *reply, DBusError *error) ret = Success; -unwind: + unwind: err = (ret == Success) ? ret : -ret; dbus_message_iter_append_basic(&reply_iter, DBUS_TYPE_INT32, &err); @@ -236,7 +205,7 @@ unwind: } static int -list_devices(DBusMessage *message, DBusMessage *reply, DBusError *error) +list_devices(DBusMessage * message, DBusMessage * reply, DBusError * error) { DeviceIntPtr dev; DBusMessageIter iter, subiter; @@ -269,7 +238,7 @@ list_devices(DBusMessage *message, DBusMessage *reply, DBusError *error) } static int -get_version(DBusMessage *message, DBusMessage *reply, DBusError *error) +get_version(DBusMessage * message, DBusMessage * reply, DBusError * error) { DBusMessageIter iter; unsigned int version = API_VERSION; @@ -284,7 +253,7 @@ get_version(DBusMessage *message, DBusMessage *reply, DBusError *error) } static DBusHandlerResult -message_handler(DBusConnection *connection, DBusMessage *message, void *data) +message_handler(DBusConnection * connection, DBusMessage * message, void *data) { DBusError error; DBusMessage *reply; @@ -333,19 +302,19 @@ message_handler(DBusConnection *connection, DBusMessage *message, void *data) ret = DBUS_HANDLER_RESULT_HANDLED; -err_reply: + err_reply: dbus_message_unref(reply); -err_start: + err_start: dbus_error_free(&error); return ret; } static void -connect_hook(DBusConnection *connection, void *data) +connect_hook(DBusConnection * connection, void *data) { DBusError error; - DBusObjectPathVTable vtable = { .message_function = message_handler, }; + DBusObjectPathVTable vtable = {.message_function = message_handler, }; struct connection_info *info = data; info->connection = connection; @@ -368,8 +337,7 @@ connect_hook(DBusConnection *connection, void *data) } if (!dbus_connection_register_object_path(info->connection, - info->busobject, &vtable, - info)) { + info->busobject, &vtable, info)) { ErrorF("[config/dbus] couldn't register object path\n"); goto err_match; } @@ -380,11 +348,11 @@ connect_hook(DBusConnection *connection, void *data) return; -err_match: + err_match: dbus_bus_remove_match(info->connection, MATCH_RULE, &error); -err_name: + err_name: dbus_bus_release_name(info->connection, info->busname, &error); -err_start: + err_start: dbus_error_free(&error); reset_info(info); @@ -404,8 +372,7 @@ pre_disconnect_hook(void) dbus_error_init(&error); dbus_connection_unregister_object_path(connection_data->connection, connection_data->busobject); - dbus_bus_remove_match(connection_data->connection, MATCH_RULE, - &error); + dbus_bus_remove_match(connection_data->connection, MATCH_RULE, &error); dbus_bus_release_name(connection_data->connection, connection_data->busname, &error); dbus_error_free(&error); @@ -413,6 +380,7 @@ pre_disconnect_hook(void) #endif static struct connection_info connection_data; + static struct config_dbus_core_hook core_hook = { .connect = connect_hook, .disconnect = disconnect_hook, diff --git a/xserver/config/hal.c b/xserver/config/hal.c index a4141d552..2ead556b0 100644 --- a/xserver/config/hal.c +++ b/xserver/config/hal.c @@ -39,11 +39,9 @@ #include "config-backends.h" #include "os.h" - #define LIBHAL_PROP_KEY "input.x11_options." #define LIBHAL_XKB_PROP_KEY "input.xkb." - struct config_hal_info { DBusConnection *system_bus; LibHalContext *hal_ctx; @@ -51,19 +49,19 @@ struct config_hal_info { /* Used for special handling of xkb options. */ struct xkb_options { - char* layout; - char* model; - char* rules; - char* variant; - char* options; + char *layout; + char *model; + char *rules; + char *variant; + char *options; }; static void -device_removed(LibHalContext *ctx, const char *udi) +device_removed(LibHalContext * ctx, const char *udi) { char *value; - if (asprintf (&value, "hal:%s", udi) == -1) + if (asprintf(&value, "hal:%s", udi) == -1) return; remove_devices("hal", value); @@ -72,12 +70,13 @@ device_removed(LibHalContext *ctx, const char *udi) } static char * -get_prop_string(LibHalContext *hal_ctx, const char *udi, const char *name) +get_prop_string(LibHalContext * hal_ctx, const char *udi, const char *name) { char *prop, *ret; prop = libhal_device_get_property_string(hal_ctx, udi, name, NULL); - LogMessageVerb(X_INFO, 10, "config/hal: getting %s on %s returned %s\n", name, udi, prop ? prop : "(null)"); + LogMessageVerb(X_INFO, 10, "config/hal: getting %s on %s returned %s\n", + name, udi, prop ? prop : "(null)"); if (prop) { ret = strdup(prop); libhal_free_string(prop); @@ -90,7 +89,8 @@ get_prop_string(LibHalContext *hal_ctx, const char *udi, const char *name) } static char * -get_prop_string_array(LibHalContext *hal_ctx, const char *udi, const char *prop) +get_prop_string_array(LibHalContext * hal_ctx, const char *udi, + const char *prop) { char **props, *ret, *str; int i, len = 0; @@ -100,7 +100,7 @@ get_prop_string_array(LibHalContext *hal_ctx, const char *udi, const char *prop) for (i = 0; props[i]; i++) len += strlen(props[i]); - ret = calloc(sizeof(char), len + i); /* i - 1 commas, 1 NULL */ + ret = calloc(sizeof(char), len + i); /* i - 1 commas, 1 NULL */ if (!ret) { libhal_free_string_array(props); return NULL; @@ -112,7 +112,7 @@ get_prop_string_array(LibHalContext *hal_ctx, const char *udi, const char *prop) str += strlen(props[i]); *str++ = ','; } - *(str-1) = '\0'; + *(str - 1) = '\0'; libhal_free_string_array(props); } @@ -124,34 +124,35 @@ get_prop_string_array(LibHalContext *hal_ctx, const char *udi, const char *prop) } static void -device_added(LibHalContext *hal_ctx, const char *udi) +device_added(LibHalContext * hal_ctx, const char *udi) { char *path = NULL, *driver = NULL, *name = NULL, *config_info = NULL; char *hal_tags, *parent; - InputOption *options = NULL, *tmpo = NULL; - InputAttributes attrs = {0}; + InputOption *input_options = NULL; + InputAttributes attrs = { 0 }; DeviceIntPtr dev = NULL; DBusError error; - struct xkb_options xkb_opts = {0}; + struct xkb_options xkb_opts = { 0 }; int rc; LibHalPropertySet *set = NULL; - LibHalPropertySetIterator set_iter; + LibHalPropertySetIterator set_iter; char *psi_key = NULL, *tmp_val; - dbus_error_init(&error); driver = get_prop_string(hal_ctx, udi, "input.x11_driver"); - if (!driver){ + if (!driver) { /* verbose, don't tell the user unless they _want_ to see it */ - LogMessageVerb(X_INFO,7,"config/hal: no driver specified for device %s\n", 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); + LogMessage(X_WARNING, + "config/hal: no driver or path specified for %s\n", udi); goto unwind; } attrs.device = strdup(path); @@ -199,71 +200,67 @@ device_added(LibHalContext *hal_ctx, const char *udi) "returned %04x\n", parent, usb_product); if (usb_vendor && usb_product) if (asprintf(&attrs.usb_id, "%04x:%04x", usb_vendor, usb_product) - == -1) - attrs.usb_id = NULL; + == -1) + attrs.usb_id = NULL; free(parent); } - options = calloc(sizeof(*options), 1); - if (!options){ - LogMessage(X_ERROR, "config/hal: couldn't allocate space for input options!\n"); - goto unwind; - } - - options->key = strdup("_source"); - options->value = strdup("server/hal"); - if (!options->key || !options->value) { - LogMessage(X_ERROR, "config/hal: couldn't allocate first key/value pair\n"); + input_options = input_option_new(NULL, "_source", "server/hal"); + if (!input_options) { + LogMessage(X_ERROR, + "config/hal: couldn't allocate first key/value pair\n"); goto unwind; } /* 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); + input_options = input_option_new(input_options, "path", path); + input_options = input_option_new(input_options, "device", path); - add_option(&options, "driver", driver); - add_option(&options, "name", name); + input_options = input_option_new(input_options, "driver", driver); + input_options = input_option_new(input_options, "name", name); - if (asprintf (&config_info, "hal:%s", udi) == -1) { + if (asprintf(&config_info, "hal:%s", udi) == -1) { config_info = NULL; LogMessage(X_ERROR, "config/hal: couldn't allocate name\n"); goto unwind; } /* Check for duplicate devices */ - if (device_is_duplicate(config_info)) - { - LogMessage(X_WARNING, "config/hal: device %s already added. Ignoring.\n", name); + if (device_is_duplicate(config_info)) { + LogMessage(X_WARNING, + "config/hal: device %s already added. Ignoring.\n", name); goto unwind; } /* ok, grab options from hal.. iterate through all properties - * and lets see if any of them are options that we can add */ + * 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); + 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); + 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); - if (psi_key){ + if (psi_key) { /* normal options first (input.x11_options.<propname>) */ - if (!strncasecmp(psi_key, LIBHAL_PROP_KEY, sizeof(LIBHAL_PROP_KEY)-1)){ - char* tmp; + if (!strncasecmp + (psi_key, LIBHAL_PROP_KEY, sizeof(LIBHAL_PROP_KEY) - 1)) { + char *tmp; /* only support strings for all values */ tmp_val = get_prop_string(hal_ctx, udi, psi_key); - if (tmp_val){ + if (tmp_val) { /* xkb needs special handling. HAL specs include * input.xkb.xyz options, but the x11-input.fdi specifies @@ -272,49 +269,53 @@ device_added(LibHalContext *hal_ctx, const char *udi) * Since we can't predict the order in which the keys * arrive, we need to store them. */ - if ((tmp = strcasestr(psi_key, "xkb")) && strlen(tmp) >= 4) - { - if (!strcasecmp(&tmp[3], "layout")) - { + if ((tmp = strcasestr(psi_key, "xkb")) && strlen(tmp) >= 4) { + if (!strcasecmp(&tmp[3], "layout")) { free(xkb_opts.layout); xkb_opts.layout = strdup(tmp_val); - } else if (!strcasecmp(&tmp[3], "model")) - { + } + else if (!strcasecmp(&tmp[3], "model")) { free(xkb_opts.model); xkb_opts.model = strdup(tmp_val); - } else if (!strcasecmp(&tmp[3], "rules")) - { + } + else if (!strcasecmp(&tmp[3], "rules")) { free(xkb_opts.rules); xkb_opts.rules = strdup(tmp_val); - } else if (!strcasecmp(&tmp[3], "variant")) - { + } + else if (!strcasecmp(&tmp[3], "variant")) { free(xkb_opts.variant); xkb_opts.variant = strdup(tmp_val); - } else if (!strcasecmp(&tmp[3], "options")) - { + } + else if (!strcasecmp(&tmp[3], "options")) { free(xkb_opts.options); xkb_opts.options = strdup(tmp_val); } - } else - { + } + else { /* all others */ - add_option(&options, psi_key + sizeof(LIBHAL_PROP_KEY)-1, tmp_val); + input_options = + input_option_new(input_options, + psi_key + sizeof(LIBHAL_PROP_KEY) - + 1, tmp_val); free(tmp_val); } - } else - { + } + else { /* server 1.4 had xkb_options as strlist. */ if ((tmp = strcasestr(psi_key, "xkb")) && (strlen(tmp) >= 4) && (!strcasecmp(&tmp[3], "options")) && - (tmp_val = get_prop_string_array(hal_ctx, udi, psi_key))) - { + (tmp_val = + get_prop_string_array(hal_ctx, udi, psi_key))) { free(xkb_opts.options); xkb_opts.options = strdup(tmp_val); } } - } else if (!strncasecmp(psi_key, LIBHAL_XKB_PROP_KEY, sizeof(LIBHAL_XKB_PROP_KEY)-1)){ - char* tmp; + } + else if (!strncasecmp + (psi_key, LIBHAL_XKB_PROP_KEY, + sizeof(LIBHAL_XKB_PROP_KEY) - 1)) { + char *tmp; /* only support strings for all values */ tmp_val = get_prop_string(hal_ctx, udi, psi_key); @@ -323,34 +324,33 @@ device_added(LibHalContext *hal_ctx, const char *udi) tmp = &psi_key[sizeof(LIBHAL_XKB_PROP_KEY) - 1]; - if (!strcasecmp(tmp, "layout")) - { + if (!strcasecmp(tmp, "layout")) { if (!xkb_opts.layout) xkb_opts.layout = strdup(tmp_val); - } else if (!strcasecmp(tmp, "rules")) - { + } + else if (!strcasecmp(tmp, "rules")) { if (!xkb_opts.rules) xkb_opts.rules = strdup(tmp_val); - } else if (!strcasecmp(tmp, "variant")) - { + } + else if (!strcasecmp(tmp, "variant")) { if (!xkb_opts.variant) xkb_opts.variant = strdup(tmp_val); - } else if (!strcasecmp(tmp, "model")) - { + } + else if (!strcasecmp(tmp, "model")) { if (!xkb_opts.model) xkb_opts.model = strdup(tmp_val); - } else if (!strcasecmp(tmp, "options")) - { + } + else if (!strcasecmp(tmp, "options")) { if (!xkb_opts.options) xkb_opts.options = strdup(tmp_val); } free(tmp_val); - } else - { + } + else { /* server 1.4 had xkb options as strlist */ tmp_val = get_prop_string_array(hal_ctx, udi, psi_key); - if (tmp_val && strlen(psi_key) >= sizeof(LIBHAL_XKB_PROP_KEY)) - { + if (tmp_val && + strlen(psi_key) >= sizeof(LIBHAL_XKB_PROP_KEY)) { tmp = &psi_key[sizeof(LIBHAL_XKB_PROP_KEY) - 1]; if (!strcasecmp(tmp, ".options") && (!xkb_opts.options)) xkb_opts.options = strdup(tmp_val); @@ -364,41 +364,41 @@ 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); + input_options = + input_option_new(input_options, "xkb_layout", xkb_opts.layout); if (xkb_opts.rules) - add_option(&options, "xkb_rules", xkb_opts.rules); + input_options = + input_option_new(input_options, "xkb_rules", xkb_opts.rules); if (xkb_opts.variant) - add_option(&options, "xkb_variant", xkb_opts.variant); + input_options = + input_option_new(input_options, "xkb_variant", xkb_opts.variant); if (xkb_opts.model) - add_option(&options, "xkb_model", xkb_opts.model); + input_options = + input_option_new(input_options, "xkb_model", xkb_opts.model); if (xkb_opts.options) - add_option(&options, "xkb_options", xkb_opts.options); - add_option(&options, "config_info", config_info); + input_options = + input_option_new(input_options, "xkb_options", xkb_opts.options); + input_options = input_option_new(input_options, "config_info", config_info); /* 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 ((rc = NewInputDeviceRequest(options, &attrs, &dev)) != Success) { - LogMessage(X_ERROR, "config/hal: NewInputDeviceRequest failed (%d)\n", rc); + if ((rc = NewInputDeviceRequest(input_options, &attrs, &dev)) != Success) { + LogMessage(X_ERROR, "config/hal: NewInputDeviceRequest failed (%d)\n", + rc); dev = NULL; goto unwind; } -unwind: + unwind: if (set) libhal_free_property_set(set); free(path); free(driver); free(name); free(config_info); - while ((tmpo = options)) { - options = tmpo->next; - free(tmpo->key); /* NULL if dev != NULL */ - free(tmpo->value); /* NULL if dev != NULL */ - free(tmpo); - } + input_option_free_list(&input_options); free(attrs.product); free(attrs.vendor); @@ -407,6 +407,7 @@ unwind: free(attrs.usb_id); if (attrs.tags) { char **tag = attrs.tags; + while (*tag) { free(*tag); tag++; @@ -435,8 +436,9 @@ disconnect_hook(void *data) if (dbus_connection_get_is_connected(info->system_bus)) { dbus_error_init(&error); if (!libhal_ctx_shutdown(info->hal_ctx, &error)) - LogMessage(X_WARNING, "config/hal: disconnect_hook couldn't shut down context: %s (%s)\n", - error.name, error.message); + LogMessage(X_WARNING, + "config/hal: disconnect_hook couldn't shut down context: %s (%s)\n", + error.name, error.message); dbus_error_free(&error); } libhal_ctx_free(info->hal_ctx); @@ -447,14 +449,14 @@ disconnect_hook(void *data) } static BOOL -connect_and_register(DBusConnection *connection, struct config_hal_info *info) +connect_and_register(DBusConnection * connection, struct config_hal_info *info) { DBusError error; char **devices; int num_devices, i; if (info->hal_ctx) - return TRUE; /* already registered, pretend we did something */ + return TRUE; /* already registered, pretend we did something */ info->system_bus = connection; @@ -467,19 +469,22 @@ connect_and_register(DBusConnection *connection, struct config_hal_info *info) } if (!libhal_ctx_set_dbus_connection(info->hal_ctx, info->system_bus)) { - LogMessage(X_ERROR, "config/hal: couldn't associate HAL context with bus\n"); + LogMessage(X_ERROR, + "config/hal: couldn't associate HAL context with bus\n"); goto out_err; } if (!libhal_ctx_init(info->hal_ctx, &error)) { - LogMessage(X_ERROR, "config/hal: couldn't initialise context: %s (%s)\n", - error.name ? error.name : "unknown error", - error.message ? error.message : "null"); + LogMessage(X_ERROR, + "config/hal: couldn't initialise context: %s (%s)\n", + error.name ? error.name : "unknown error", + error.message ? error.message : "null"); goto out_err; } if (!libhal_device_property_watch_all(info->hal_ctx, &error)) { - LogMessage(X_ERROR, "config/hal: couldn't watch all properties: %s (%s)\n", - error.name ? error.name : "unknown error", - error.message ? error.message : "null"); + LogMessage(X_ERROR, + "config/hal: couldn't watch all properties: %s (%s)\n", + error.name ? error.name : "unknown error", + error.message ? error.message : "null"); goto out_ctx; } libhal_ctx_set_device_added(info->hal_ctx, device_added); @@ -490,8 +495,8 @@ connect_and_register(DBusConnection *connection, struct config_hal_info *info) /* FIXME: Get default devices if error is set. */ if (dbus_error_is_set(&error)) { LogMessage(X_ERROR, "config/hal: couldn't find input device: %s (%s)\n", - error.name ? error.name : "unknown error", - error.message ? error.message : "null"); + error.name ? error.name : "unknown error", + error.message ? error.message : "null"); goto out_ctx; } for (i = 0; i < num_devices; i++) @@ -502,17 +507,18 @@ connect_and_register(DBusConnection *connection, struct config_hal_info *info) return TRUE; -out_ctx: + out_ctx: dbus_error_free(&error); if (!libhal_ctx_shutdown(info->hal_ctx, &error)) { - LogMessage(X_WARNING, "config/hal: couldn't shut down context: %s (%s)\n", - error.name ? error.name : "unknown error", - error.message ? error.message : "null"); + LogMessage(X_WARNING, + "config/hal: couldn't shut down context: %s (%s)\n", + error.name ? error.name : "unknown error", + error.message ? error.message : "null"); dbus_error_free(&error); } -out_err: + out_err: dbus_error_free(&error); if (info->hal_ctx) { @@ -525,7 +531,6 @@ out_err: return FALSE; } - /** * Handle NewOwnerChanged signals to deal with HAL startup at X server runtime. * @@ -535,13 +540,13 @@ out_err: * owner. */ static DBusHandlerResult -ownerchanged_handler(DBusConnection *connection, DBusMessage *message, void *data) +ownerchanged_handler(DBusConnection * connection, DBusMessage * message, + void *data) { int ret = DBUS_HANDLER_RESULT_NOT_YET_HANDLED; if (dbus_message_is_signal(message, - "org.freedesktop.DBus", - "NameOwnerChanged")) { + "org.freedesktop.DBus", "NameOwnerChanged")) { DBusError error; char *name, *old_owner, *new_owner; @@ -549,19 +554,21 @@ ownerchanged_handler(DBusConnection *connection, DBusMessage *message, void *dat dbus_message_get_args(message, &error, DBUS_TYPE_STRING, &name, DBUS_TYPE_STRING, &old_owner, - DBUS_TYPE_STRING, &new_owner, - DBUS_TYPE_INVALID); + DBUS_TYPE_STRING, &new_owner, DBUS_TYPE_INVALID); if (dbus_error_is_set(&error)) { - ErrorF("[config/hal] failed to get NameOwnerChanged args: %s (%s)\n", - error.name, error.message); - } else if (name && strcmp(name, "org.freedesktop.Hal") == 0) { + ErrorF + ("[config/hal] failed to get NameOwnerChanged args: %s (%s)\n", + error.name, error.message); + } + else if (name && strcmp(name, "org.freedesktop.Hal") == 0) { if (!old_owner || !strlen(old_owner)) { DebugF("[config/hal] HAL startup detected.\n"); - if (connect_and_register(connection, (struct config_hal_info*)data)) + if (connect_and_register + (connection, (struct config_hal_info *) data)) dbus_connection_unregister_object_path(connection, - "/org/freedesktop/DBus"); + "/org/freedesktop/DBus"); else ErrorF("[config/hal] Failed to connect to HAL bus.\n"); } @@ -578,30 +585,29 @@ ownerchanged_handler(DBusConnection *connection, DBusMessage *message, void *dat * Register a handler for the NameOwnerChanged signal. */ static BOOL -listen_for_startup(DBusConnection *connection, void *data) +listen_for_startup(DBusConnection * connection, void *data) { - DBusObjectPathVTable vtable = { .message_function = ownerchanged_handler, }; + DBusObjectPathVTable vtable = {.message_function = ownerchanged_handler, }; DBusError error; const char MATCH_RULE[] = "sender='org.freedesktop.DBus'," - "interface='org.freedesktop.DBus'," - "type='signal'," - "path='/org/freedesktop/DBus'," - "member='NameOwnerChanged'"; + "interface='org.freedesktop.DBus'," + "type='signal'," + "path='/org/freedesktop/DBus'," "member='NameOwnerChanged'"; int rc = FALSE; dbus_error_init(&error); dbus_bus_add_match(connection, MATCH_RULE, &error); if (!dbus_error_is_set(&error)) { if (dbus_connection_register_object_path(connection, - "/org/freedesktop/DBus", - &vtable, - data)) + "/org/freedesktop/DBus", + &vtable, data)) rc = TRUE; else ErrorF("[config/hal] cannot register object path.\n"); - } else { + } + else { ErrorF("[config/hal] couldn't add match rule: %s (%s)\n", error.name, - error.message); + error.message); ErrorF("[config/hal] cannot detect a HAL startup.\n"); } @@ -611,7 +617,7 @@ listen_for_startup(DBusConnection *connection, void *data) } static void -connect_hook(DBusConnection *connection, void *data) +connect_hook(DBusConnection * connection, void *data) { struct config_hal_info *info = data; @@ -624,6 +630,7 @@ connect_hook(DBusConnection *connection, void *data) } static struct config_hal_info hal_info; + static struct config_dbus_core_hook hook = { .connect = connect_hook, .disconnect = disconnect_hook, @@ -643,7 +650,7 @@ config_hal_init(void) } /* verbose message */ - LogMessageVerb(X_INFO,7,"config/hal: initialized\n"); + LogMessageVerb(X_INFO, 7, "config/hal: initialized\n"); return 1; } diff --git a/xserver/config/udev.c b/xserver/config/udev.c index 42713e92d..8b3ca0475 100644 --- a/xserver/config/udev.c +++ b/xserver/config/udev.c @@ -35,6 +35,7 @@ #include "hotplug.h" #include "config-backends.h" #include "os.h" +#include "globals.h" #define UDEV_XKB_PROP_KEY "xkb" @@ -59,12 +60,13 @@ device_added(struct udev_device *udev_device) const char *syspath; const char *tags_prop; const char *key, *value, *tmp; - InputOption *options = NULL, *tmpo; - InputAttributes attrs = {}; + InputOption *input_options; + InputAttributes attrs = { }; DeviceIntPtr dev = NULL; struct udev_list_entry *set, *entry; struct udev_device *parent; int rc; + const char *dev_seat; path = udev_device_get_devnode(udev_device); @@ -73,23 +75,27 @@ device_added(struct udev_device *udev_device) if (!path || !syspath) return; + dev_seat = udev_device_get_property_value(udev_device, "ID_SEAT"); + if (!dev_seat) + dev_seat = "seat0"; + + if (SeatId && strcmp(dev_seat, SeatId)) + return; + + if (!SeatId && strcmp(dev_seat, "seat0")) + return; + if (!udev_device_get_property_value(udev_device, "ID_INPUT")) { LogMessageVerb(X_INFO, 10, "config/udev: ignoring device %s without " - "property ID_INPUT set\n", - path); + "property ID_INPUT set\n", path); return; } - options = calloc(sizeof(*options), 1); - if (!options) + input_options = input_option_new(NULL, "_source", "server/udev"); + if (!input_options) return; - options->key = strdup("_source"); - options->value = strdup("server/udev"); - if (!options->key || !options->value) - goto unwind; - parent = udev_device_get_parent(udev_device); if (parent) { const char *ppath = udev_device_get_devnode(parent); @@ -109,7 +115,8 @@ device_added(struct udev_device *udev_device) LOG_SYSATTR(ppath, "id", pnp_id); /* construct USB ID in lowercase hex - "0000:ffff" */ - if (product && sscanf(product, "%*x/%4x/%4x/%*x", &usb_vendor, &usb_model) == 2) { + if (product && + sscanf(product, "%*x/%4x/%4x/%*x", &usb_vendor, &usb_model) == 2) { if (asprintf(&attrs.usb_id, "%04x:%04x", usb_vendor, usb_model) == -1) attrs.usb_id = NULL; @@ -121,10 +128,9 @@ device_added(struct udev_device *udev_device) name = "(unnamed)"; else attrs.product = strdup(name); - add_option(&options, "name", name); - - add_option(&options, "path", path); - add_option(&options, "device", path); + input_options = input_option_new(input_options, "name", name); + input_options = input_option_new(input_options, "path", path); + input_options = input_option_new(input_options, "device", path); if (path) attrs.device = strdup(path); @@ -139,7 +145,7 @@ device_added(struct udev_device *udev_device) if (device_is_duplicate(config_info)) { LogMessage(X_WARNING, "config/udev: device %s already added. " - "Ignoring.\n", name); + "Ignoring.\n", name); goto unwind; } @@ -149,60 +155,66 @@ device_added(struct udev_device *udev_device) if (!key) continue; value = udev_list_entry_get_value(entry); - if (!strncasecmp(key, UDEV_XKB_PROP_KEY, - sizeof(UDEV_XKB_PROP_KEY) - 1)) { + if (!strncasecmp(key, UDEV_XKB_PROP_KEY, sizeof(UDEV_XKB_PROP_KEY) - 1)) { LOG_PROPERTY(path, key, value); tmp = key + sizeof(UDEV_XKB_PROP_KEY) - 1; if (!strcasecmp(tmp, "rules")) - add_option(&options, "xkb_rules", value); + input_options = + input_option_new(input_options, "xkb_rules", value); else if (!strcasecmp(tmp, "layout")) - add_option(&options, "xkb_layout", value); + input_options = + input_option_new(input_options, "xkb_layout", value); else if (!strcasecmp(tmp, "variant")) - add_option(&options, "xkb_variant", value); + input_options = + input_option_new(input_options, "xkb_variant", value); else if (!strcasecmp(tmp, "model")) - add_option(&options, "xkb_model", value); + input_options = + input_option_new(input_options, "xkb_model", value); else if (!strcasecmp(tmp, "options")) - add_option(&options, "xkb_options", value); - } else if (!strcmp(key, "ID_VENDOR")) { + input_options = + input_option_new(input_options, "xkb_options", value); + } + else if (!strcmp(key, "ID_VENDOR")) { LOG_PROPERTY(path, key, value); attrs.vendor = strdup(value); - } else if (!strcmp(key, "ID_INPUT_KEY")) { + } + else if (!strcmp(key, "ID_INPUT_KEY")) { LOG_PROPERTY(path, key, value); attrs.flags |= ATTR_KEYBOARD; - } else if (!strcmp(key, "ID_INPUT_MOUSE")) { + } + else if (!strcmp(key, "ID_INPUT_MOUSE")) { LOG_PROPERTY(path, key, value); attrs.flags |= ATTR_POINTER; - } else if (!strcmp(key, "ID_INPUT_JOYSTICK")) { + } + else if (!strcmp(key, "ID_INPUT_JOYSTICK")) { LOG_PROPERTY(path, key, value); attrs.flags |= ATTR_JOYSTICK; - } else if (!strcmp(key, "ID_INPUT_TABLET")) { + } + else if (!strcmp(key, "ID_INPUT_TABLET")) { LOG_PROPERTY(path, key, value); attrs.flags |= ATTR_TABLET; - } else if (!strcmp(key, "ID_INPUT_TOUCHPAD")) { + } + else if (!strcmp(key, "ID_INPUT_TOUCHPAD")) { LOG_PROPERTY(path, key, value); attrs.flags |= ATTR_TOUCHPAD; - } else if (!strcmp(key, "ID_INPUT_TOUCHSCREEN")) { + } + else if (!strcmp(key, "ID_INPUT_TOUCHSCREEN")) { LOG_PROPERTY(path, key, value); attrs.flags |= ATTR_TOUCHSCREEN; } } - add_option(&options, "config_info", config_info); + input_options = input_option_new(input_options, "config_info", config_info); LogMessage(X_INFO, "config/udev: Adding input device %s (%s)\n", name, path); - rc = NewInputDeviceRequest(options, &attrs, &dev); + rc = NewInputDeviceRequest(input_options, &attrs, &dev); if (rc != Success) goto unwind; unwind: free(config_info); - while ((tmpo = options)) { - options = tmpo->next; - free(tmpo->key); /* NULL if dev != NULL */ - free(tmpo->value); /* NULL if dev != NULL */ - free(tmpo); - } + input_option_free_list(&input_options); free(attrs.usb_id); free(attrs.pnp_id); @@ -211,6 +223,7 @@ device_added(struct udev_device *udev_device) free(attrs.vendor); if (attrs.tags) { char **tag = attrs.tags; + while (*tag) { free(*tag); tag++; @@ -245,7 +258,7 @@ wakeup_handler(pointer data, int err, pointer read_mask) if (err < 0) return; - if (FD_ISSET(udev_fd, (fd_set *)read_mask)) { + if (FD_ISSET(udev_fd, (fd_set *) read_mask)) { udev_device = udev_monitor_receive_device(udev_monitor); if (!udev_device) return; @@ -281,9 +294,15 @@ config_udev_init(void) if (!udev_monitor) return 0; - udev_monitor_filter_add_match_subsystem_devtype(udev_monitor, "input", NULL); + udev_monitor_filter_add_match_subsystem_devtype(udev_monitor, "input", + NULL); udev_monitor_filter_add_match_subsystem_devtype(udev_monitor, "tty", NULL); /* For Wacom serial devices */ +#ifdef HAVE_UDEV_MONITOR_FILTER_ADD_MATCH_TAG + if (SeatId && strcmp(SeatId, "seat0")) + udev_monitor_filter_add_match_tag(udev_monitor, SeatId); +#endif + if (udev_monitor_enable_receiving(udev_monitor)) { ErrorF("config/udev: failed to bind the udev monitor\n"); return 0; @@ -296,11 +315,17 @@ config_udev_init(void) udev_enumerate_add_match_subsystem(enumerate, "input"); udev_enumerate_add_match_subsystem(enumerate, "tty"); +#ifdef HAVE_UDEV_ENUMERATE_ADD_MATCH_TAG + if (SeatId && strcmp(SeatId, "seat0")) + udev_enumerate_add_match_tag(enumerate, SeatId); +#endif + udev_enumerate_scan_devices(enumerate); devices = udev_enumerate_get_list_entry(enumerate); udev_list_entry_foreach(device, devices) { const char *syspath = udev_list_entry_get_name(device); - struct udev_device *udev_device = udev_device_new_from_syspath(udev, syspath); + struct udev_device *udev_device = + udev_device_new_from_syspath(udev, syspath); /* Device might be gone by the time we try to open it */ if (!udev_device) diff --git a/xserver/config/wscons.c b/xserver/config/wscons.c index cbfc2299f..9b69e7037 100644 --- a/xserver/config/wscons.c +++ b/xserver/config/wscons.c @@ -50,231 +50,216 @@ { KB_CF, "ca" } struct nameint { - int val; - char *name; -} kbdenc[] = { KB_OVRENC, KB_ENCTAB, { 0 } }; + int val; + char *name; +} kbdenc[] = { + KB_OVRENC, KB_ENCTAB, { +0}}; struct nameint kbdvar[] = { - { KB_NODEAD | KB_SG, "de_nodeadkeys" }, - { KB_NODEAD | KB_SF, "fr_nodeadkeys" }, - { KB_SF, "fr" }, - { KB_DVORAK | KB_CF, "fr-dvorak" }, - { KB_DVORAK | KB_FR, "bepo" }, - { KB_DVORAK, "dvorak" }, - { KB_CF, "fr-legacy" }, - { KB_NODEAD, "nodeadkeys" }, - { 0 } + {KB_NODEAD | KB_SG, "de_nodeadkeys"}, + {KB_NODEAD | KB_SF, "fr_nodeadkeys"}, + {KB_SF, "fr"}, + {KB_DVORAK | KB_CF, "fr-dvorak"}, + {KB_DVORAK | KB_FR, "bepo"}, + {KB_DVORAK, "dvorak"}, + {KB_CF, "fr-legacy"}, + {KB_NODEAD, "nodeadkeys"}, + {0} }; struct nameint kbdopt[] = { - { KB_SWAPCTRLCAPS, "ctrl:swapcaps" }, - { 0 } + {KB_SWAPCTRLCAPS, "ctrl:swapcaps"}, + {0} }; struct nameint kbdmodel[] = { - { WSKBD_TYPE_ZAURUS, "zaurus" }, - { WSKBD_TYPE_ADB, "macintosh" }, - { 0 } + {WSKBD_TYPE_ZAURUS, "zaurus"}, + {WSKBD_TYPE_ADB, "macintosh" }, + {0} }; -extern int priv_open_device(const char *); - static void wscons_add_keyboard(void) { - InputAttributes attrs = {}; - DeviceIntPtr dev = NULL; - InputOption *options = NULL, *tmpo; - char *config_info = NULL; - int fd, i, rc; - unsigned int type; - kbd_t wsenc = 0; - - /* Find keyboard configuration */ - fd = priv_open_device(WSCONS_KBD_DEVICE); - if (fd == -1) { - LogMessage(X_ERROR, "wskbd: open %s: %s\n", - WSCONS_KBD_DEVICE, strerror(errno)); - return; - } - if (ioctl(fd, WSKBDIO_GETENCODING, &wsenc) == -1) { - LogMessage(X_WARNING, "wskbd: ioctl(WSKBDIO_GETENCODING) " - "failed: %s\n", strerror(errno)); - close(fd); - return; - } - if (ioctl(fd, WSKBDIO_GTYPE, &type) == -1) { - LogMessage(X_WARNING, "wskbd: ioctl(WSKBDIO_GTYPE) " - "failed: %s\n", strerror(errno)); - close(fd); - return; - } - close (fd); + InputAttributes attrs = { }; + DeviceIntPtr dev = NULL; + InputOption *input_options = NULL; + char *config_info = NULL; + int fd, i, rc; + unsigned int type; + kbd_t wsenc = 0; - options = calloc(sizeof(*options), 1); - if (!options) - return; + /* Find keyboard configuration */ + fd = priv_open_device(WSCONS_KBD_DEVICE); + if (fd == -1) { + LogMessage(X_ERROR, "wskbd: open %s: %s\n", + WSCONS_KBD_DEVICE, strerror(errno)); + return; + } + if (ioctl(fd, WSKBDIO_GETENCODING, &wsenc) == -1) { + LogMessage(X_WARNING, "wskbd: ioctl(WSKBDIO_GETENCODING) " + "failed: %s\n", strerror(errno)); + close(fd); + return; + } + if (ioctl(fd, WSKBDIO_GTYPE, &type) == -1) { + LogMessage(X_WARNING, "wskbd: ioctl(WSKBDIO_GTYPE) " + "failed: %s\n", strerror(errno)); + close(fd); + return; + } + close (fd); - options->key = strdup("_source"); - options->value = strdup("server/wscons"); - if (!options->key || !options->value) - return; + input_options = input_option_new(input_options, "_source", "server/wscons"); + if (input_options == NULL) + return; - LogMessage(X_INFO, "config/wscons: checking input device %s\n", - WSCONS_KBD_DEVICE); - add_option(&options, "name", WSCONS_KBD_DEVICE); - add_option(&options, "driver", "kbd"); + LogMessage(X_INFO, "config/wscons: checking input device %s\n", + WSCONS_KBD_DEVICE); + input_options = input_option_new(input_options, "name", WSCONS_KBD_DEVICE); + input_options = input_option_new(input_options, "driver", "kbd"); - config_info = Xprintf("wscons:%s", WSCONS_KBD_DEVICE); - if (!config_info) - goto unwind; - if (KB_ENCODING(wsenc) == KB_USER) { - /* Ignore wscons "user" layout */ - LogMessageVerb(X_INFO, 3, "wskbd: ignoring \"user\" layout\n"); - goto kbd_config_done; - } - for (i = 0; kbdenc[i].val; i++) - if(KB_ENCODING(wsenc) == kbdenc[i].val) { - LogMessageVerb(X_INFO, 3, "wskbd: using layout %s\n", - kbdenc[i].name); - add_option(&options, "xkb_layout", kbdenc[i].name); - break; - } - for (i = 0; kbdvar[i].val; i++) - if (wsenc == kbdvar[i].val || - KB_VARIANT(wsenc) == kbdvar[i].val) { - LogMessageVerb(X_INFO, 3, "wskbd: using variant %s\n", - kbdvar[i].name); - add_option(&options, "xkb_variant", kbdvar[i].name); - break; - } - for (i = 0; kbdopt[i].val; i++) - if (KB_VARIANT(wsenc) == kbdopt[i].val) { - LogMessageVerb(X_INFO, 3, "wskbd: using option %s\n", - kbdopt[i].name); - add_option(&options, "xkb_options", kbdopt[i].name); - break; - } - for (i = 0; kbdmodel[i].val; i++) - if (type == kbdmodel[i].val) { - LogMessageVerb(X_INFO, 3, "wskbd: using model %s\n", - kbdmodel[i].name); - add_option(&options, "xkb_model", kbdmodel[i].name); - break; - } + config_info = Xprintf("wscons:%s", WSCONS_KBD_DEVICE); + if (!config_info) + goto unwind; + if (KB_ENCODING(wsenc) == KB_USER) { + /* Ignore wscons "user" layout */ + LogMessageVerb(X_INFO, 3, "wskbd: ignoring \"user\" layout\n"); + goto kbd_config_done; + } + for (i = 0; kbdenc[i].val; i++) + if (KB_ENCODING(wsenc) == kbdenc[i].val) { + LogMessageVerb(X_INFO, 3, "wskbd: using layout %s\n", + kbdenc[i].name); + input_options = input_option_new(input_options, + "xkb_layout", kbdenc[i].name); + break; + } + for (i = 0; kbdvar[i].val; i++) + if (wsenc == kbdvar[i].val || KB_VARIANT(wsenc) == kbdvar[i].val) { + LogMessageVerb(X_INFO, 3, "wskbd: using variant %s\n", + kbdvar[i].name); + input_options = input_option_new(input_options, + "xkb_variant", kbdvar[i].name); + break; + } + for (i = 0; kbdopt[i].val; i++) + if (KB_VARIANT(wsenc) == kbdopt[i].val) { + LogMessageVerb(X_INFO, 3, "wskbd: using option %s\n", + kbdopt[i].name); + input_options = input_option_new(input_options, + "xkb_options", kbdopt[i].name); + break; + } + for (i = 0; kbdmodel[i].val; i++) + if (type == kbdmodel[i].val) { + LogMessageVerb(X_INFO, 3, "wskbd: using model %s\n", + kbdmodel[i].name); + input_options = input_option_new(input_options, + "xkb_model", kbdmodel[i].name); + break; + } -kbd_config_done: - attrs.flags |= ATTR_KEYBOARD; - rc = NewInputDeviceRequest(options, &attrs, &dev); - if (rc != Success) - goto unwind; + kbd_config_done: + attrs.flags |= ATTR_KEYBOARD; + rc = NewInputDeviceRequest(input_options, &attrs, &dev); + if (rc != Success) + goto unwind; - for (; dev; dev = dev->next) { - free(dev->config_info); - dev->config_info = strdup(config_info); - } -unwind: - while (!dev && (tmpo = options)) { - options = tmpo->next; - free(tmpo->key); - free(tmpo->value); - free(tmpo); + for (; dev; dev = dev->next) { + free(dev->config_info); + dev->config_info = strdup(config_info); } + unwind: + input_option_free_list(&input_options); } static void wscons_add_pointer(const char *path, const char *driver, int flags) { - InputAttributes attrs = {}; - DeviceIntPtr dev = NULL; - InputOption *options = NULL, *tmpo; - char *config_info = NULL; - int rc; + InputAttributes attrs = { }; + DeviceIntPtr dev = NULL; + InputOption *input_options = NULL; + char *config_info = NULL; + int rc; - config_info = Xprintf("wscons:%s", path); - if (!config_info) - return; - options = calloc(sizeof(*options), 1); - if (!options) - return; + config_info = Xprintf("wscons:%s", path); + if (!config_info) + return; - options->key = strdup("_source"); - options->value = strdup("server/wscons"); - if (!options->key || !options->value) - return; - add_option(&options, "name", strdup(path)); - add_option(&options, "driver", strdup(driver)); - add_option(&options, "device", strdup(path)); - LogMessage(X_INFO, "config/wscons: checking input device %s\n", path); - attrs.flags |= flags; - rc = NewInputDeviceRequest(options, &attrs, &dev); - if (rc != Success) - goto unwind; + input_options = input_option_new(input_options, "_source", "server/wscons"); + if (input_options == NULL) + return; - for (; dev; dev = dev->next) { - free(dev->config_info); - dev->config_info = strdup(config_info); - } -unwind: - while (!dev && (tmpo = options)) { - options = tmpo->next; - free(tmpo->key); - free(tmpo->value); - free(tmpo); + input_options = input_option_new(input_options, "name", strdup(path)); + input_options = input_option_new(input_options, "driver", strdup(driver)); + input_options = input_option_new(input_options, "device", strdup(path)); + LogMessage(X_INFO, "config/wscons: checking input device %s\n", path); + attrs.flags |= flags; + rc = NewInputDeviceRequest(input_options, &attrs, &dev); + if (rc != Success) + goto unwind; + + for (; dev; dev = dev->next) { + free(dev->config_info); + dev->config_info = strdup(config_info); } + unwind: + input_option_free_list(&input_options); } static void wscons_add_pointers(void) { - char devname[256]; - int fd, i, wsmouse_type; + char devname[256]; + int fd, i, wsmouse_type; - /* Check pointing devices */ - for (i = 0; i < 4; i++) { - snprintf(devname, sizeof(devname), "%s%d", - WSCONS_MOUSE_PREFIX, i); - LogMessageVerb(X_INFO, 10, "wsmouse: checking %s\n", devname); - fd = priv_open_device(devname); - if (fd == -1) { - LogMessageVerb(X_WARNING, 10, "%s: %s\n", devname, - strerror(errno)); - continue; - } - if (ioctl(fd, WSMOUSEIO_GTYPE, &wsmouse_type) != 0) { - LogMessageVerb(X_WARNING, 10, - "%s: WSMOUSEIO_GTYPE failed\n", devname); - close(fd); - continue; - } - close(fd); - switch (wsmouse_type) { - case WSMOUSE_TYPE_SYNAPTICS: - case WSMOUSE_TYPE_ALPS: - wscons_add_pointer(devname, "synaptics", - ATTR_TOUCHPAD); - break; - case WSMOUSE_TYPE_TPANEL: - wscons_add_pointer(devname, "ws", ATTR_TOUCHSCREEN); - break; - default: - break; - } - } - /* Add a default entry catching all other mux elements as "ws" */ - wscons_add_pointer(WSCONS_MOUSE_PREFIX, "ws", ATTR_POINTER); + /* Check pointing devices */ + for (i = 0; i < 4; i++) { + snprintf(devname, sizeof(devname), "%s%d", + WSCONS_MOUSE_PREFIX, i); + LogMessageVerb(X_INFO, 10, "wsmouse: checking %s\n", devname); + fd = priv_open_device(devname); + if (fd == -1) { + LogMessageVerb(X_WARNING, 10, "%s: %s\n", devname, + strerror(errno)); + continue; + } + if (ioctl(fd, WSMOUSEIO_GTYPE, &wsmouse_type) != 0) { + LogMessageVerb(X_WARNING, 10, + "%s: WSMOUSEIO_GTYPE failed\n", devname); + close(fd); + continue; + } + close(fd); + switch (wsmouse_type) { + case WSMOUSE_TYPE_SYNAPTICS: + case WSMOUSE_TYPE_ALPS: + wscons_add_pointer(devname, "synaptics", + ATTR_TOUCHPAD); + break; + case WSMOUSE_TYPE_TPANEL: + wscons_add_pointer(devname, "ws", ATTR_TOUCHSCREEN); + break; + default: + break; + } + } + /* Add a default entry catching all other mux elements as "ws" */ + wscons_add_pointer(WSCONS_MOUSE_PREFIX, "ws", ATTR_POINTER); } int config_wscons_init(void) { - wscons_add_keyboard(); - wscons_add_pointers(); - return 1; + wscons_add_keyboard(); + wscons_add_pointers(); + return 1; } void config_wscons_fini(void) { - /* Not much to do ? */ + /* Not much to do ? */ } |