Merge branch 'server-1.5-branch' into xorg-server-1.5-apple
This commit is contained in:
commit
1e54d7a8d1
62
config/hal.c
62
config/hal.c
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright © 2007 Daniel Stone
|
||||
* Copyright © 2007 Red Hat, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
|
@ -54,6 +55,7 @@ struct xkb_options {
|
|||
char* model;
|
||||
char* rules;
|
||||
char* variant;
|
||||
char* options;
|
||||
};
|
||||
|
||||
|
||||
|
@ -130,9 +132,6 @@ 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
|
||||
* the future. */
|
||||
#if 0
|
||||
static char *
|
||||
get_prop_string_array(LibHalContext *hal_ctx, const char *udi, const char *prop)
|
||||
{
|
||||
|
@ -166,7 +165,6 @@ get_prop_string_array(LibHalContext *hal_ctx, const char *udi, const char *prop)
|
|||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
device_added(LibHalContext *hal_ctx, const char *udi)
|
||||
|
@ -248,12 +246,12 @@ device_added(LibHalContext *hal_ctx, const char *udi)
|
|||
|
||||
/* normal options first (input.x11_options.<propname>) */
|
||||
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){
|
||||
char* tmp;
|
||||
|
||||
/* xkb needs special handling. HAL specs include
|
||||
* input.xkb.xyz options, but the x11-input.fdi specifies
|
||||
|
@ -262,17 +260,7 @@ 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.
|
||||
*/
|
||||
#ifndef HAVE_STRCASESTR
|
||||
int psi_key_len = strlen(psi_key);
|
||||
char *lower_psi_key = xalloc(psi_key_len + 1);
|
||||
|
||||
CopyISOLatin1Lowered((unsigned char *) lower_psi_key,
|
||||
(unsigned char *) psi_key,
|
||||
psi_key_len);
|
||||
if ((tmp = strstr(lower_psi_key, "xkb")))
|
||||
#else
|
||||
if ((tmp = strcasestr(psi_key, "xkb")))
|
||||
#endif
|
||||
if ((tmp = strcasestr(psi_key, "xkb")) && strlen(tmp) >= 4)
|
||||
{
|
||||
if (!strcasecmp(&tmp[3], "layout"))
|
||||
{
|
||||
|
@ -294,6 +282,11 @@ device_added(LibHalContext *hal_ctx, const char *udi)
|
|||
if (xkb_opts.variant)
|
||||
xfree(xkb_opts.variant);
|
||||
xkb_opts.variant = strdup(tmp_val);
|
||||
} else if (!strcasecmp(&tmp[3], "options"))
|
||||
{
|
||||
if (xkb_opts.options)
|
||||
xfree(xkb_opts.options);
|
||||
xkb_opts.options = strdup(tmp_val);
|
||||
}
|
||||
} else
|
||||
{
|
||||
|
@ -301,17 +294,26 @@ device_added(LibHalContext *hal_ctx, const char *udi)
|
|||
add_option(&options, psi_key + sizeof(LIBHAL_PROP_KEY)-1, tmp_val);
|
||||
xfree(tmp_val);
|
||||
}
|
||||
#ifndef HAVE_STRCASESTR
|
||||
xfree(lower_psi_key);
|
||||
#endif
|
||||
} 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)))
|
||||
{
|
||||
if (xkb_opts.options)
|
||||
xfree(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;
|
||||
|
||||
/* only support strings for all values */
|
||||
tmp_val = get_prop_string(hal_ctx, udi, psi_key);
|
||||
|
||||
if (tmp_val){
|
||||
char* tmp;
|
||||
if (tmp_val && strlen(psi_key) >= sizeof(LIBHAL_XKB_PROP_KEY)) {
|
||||
|
||||
tmp = &psi_key[sizeof(LIBHAL_XKB_PROP_KEY) - 1];
|
||||
|
||||
|
@ -331,8 +333,22 @@ device_added(LibHalContext *hal_ctx, const char *udi)
|
|||
{
|
||||
if (!xkb_opts.model)
|
||||
xkb_opts.model = strdup(tmp_val);
|
||||
} else if (!strcasecmp(tmp, "options"))
|
||||
{
|
||||
if (!xkb_opts.options)
|
||||
xkb_opts.options = strdup(tmp_val);
|
||||
}
|
||||
xfree(tmp_val);
|
||||
} 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))
|
||||
{
|
||||
tmp = &psi_key[sizeof(LIBHAL_XKB_PROP_KEY) - 1];
|
||||
if (!strcasecmp(tmp, ".options") && (!xkb_opts.options))
|
||||
xkb_opts.options = strdup(tmp_val);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -351,6 +367,8 @@ device_added(LibHalContext *hal_ctx, const char *udi)
|
|||
add_option(&options, "xkb_variant", xkb_opts.variant);
|
||||
if (xkb_opts.model)
|
||||
add_option(&options, "xkb_model", xkb_opts.model);
|
||||
if (xkb_opts.options)
|
||||
add_option(&options, "xkb_options", xkb_opts.options);
|
||||
|
||||
/* 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);
|
||||
|
@ -392,6 +410,8 @@ unwind:
|
|||
xfree(xkb_opts.model);
|
||||
if (xkb_opts.variant)
|
||||
xfree(xkb_opts.variant);
|
||||
if (xkb_opts.options)
|
||||
xfree(xkb_opts.options);
|
||||
|
||||
dbus_error_free(&error);
|
||||
|
||||
|
|
|
@ -1324,7 +1324,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
|
|||
}
|
||||
|
||||
/* 3. First core pointer device. */
|
||||
if (!foundPointer) {
|
||||
if (!foundPointer && (!xf86Info.allowEmptyInput || implicitLayout)) {
|
||||
XF86ConfInputPtr p;
|
||||
|
||||
for (p = xf86configptr->conf_input_lst; p; p = p->list.next) {
|
||||
|
@ -1340,7 +1340,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
|
|||
}
|
||||
|
||||
/* 4. First pointer with 'mouse' as the driver. */
|
||||
if (!foundPointer) {
|
||||
if (!foundPointer && (!xf86Info.allowEmptyInput || implicitLayout)) {
|
||||
confInput = xf86findInput(CONF_IMPLICIT_POINTER,
|
||||
xf86configptr->conf_input_lst);
|
||||
if (!confInput) {
|
||||
|
@ -1355,7 +1355,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
|
|||
}
|
||||
|
||||
/* 5. Built-in default. */
|
||||
if (!foundPointer) {
|
||||
if (!foundPointer && !xf86Info.allowEmptyInput) {
|
||||
bzero(&defPtr, sizeof(defPtr));
|
||||
defPtr.inp_identifier = strdup("<default pointer>");
|
||||
defPtr.inp_driver = strdup("mouse");
|
||||
|
@ -1382,9 +1382,13 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
|
|||
}
|
||||
|
||||
if (!foundPointer) {
|
||||
/* This shouldn't happen. */
|
||||
xf86Msg(X_ERROR, "Cannot locate a core pointer device.\n");
|
||||
return FALSE;
|
||||
if (!xf86Info.allowEmptyInput) {
|
||||
/* This shouldn't happen. */
|
||||
xf86Msg(X_ERROR, "Cannot locate a core pointer device.\n");
|
||||
return FALSE;
|
||||
} else {
|
||||
xf86Msg(X_INFO, "Cannot locate a core pointer device.\n");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1401,7 +1405,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
|
|||
found = 1; break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
if (!found && !xf86Info.allowEmptyInput) {
|
||||
xf86Msg(X_INFO, "No default mouse found, adding one\n");
|
||||
bzero(&defPtr, sizeof(defPtr));
|
||||
defPtr.inp_identifier = strdup("<default pointer>");
|
||||
|
@ -1460,7 +1464,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
|
|||
}
|
||||
|
||||
/* 3. First core keyboard device. */
|
||||
if (!foundKeyboard) {
|
||||
if (!foundKeyboard && (!xf86Info.allowEmptyInput || implicitLayout)) {
|
||||
XF86ConfInputPtr p;
|
||||
|
||||
for (p = xf86configptr->conf_input_lst; p; p = p->list.next) {
|
||||
|
@ -1476,7 +1480,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
|
|||
}
|
||||
|
||||
/* 4. First keyboard with 'keyboard' or 'kbd' as the driver. */
|
||||
if (!foundKeyboard) {
|
||||
if (!foundKeyboard && (!xf86Info.allowEmptyInput || implicitLayout)) {
|
||||
confInput = xf86findInput(CONF_IMPLICIT_KEYBOARD,
|
||||
xf86configptr->conf_input_lst);
|
||||
if (!confInput) {
|
||||
|
@ -1491,7 +1495,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
|
|||
}
|
||||
|
||||
/* 5. Built-in default. */
|
||||
if (!foundKeyboard) {
|
||||
if (!foundKeyboard && !xf86Info.allowEmptyInput) {
|
||||
bzero(&defKbd, sizeof(defKbd));
|
||||
defKbd.inp_identifier = strdup("<default keyboard>");
|
||||
defKbd.inp_driver = strdup("kbd");
|
||||
|
@ -1518,21 +1522,39 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
|
|||
}
|
||||
|
||||
if (!foundKeyboard) {
|
||||
/* This shouldn't happen. */
|
||||
xf86Msg(X_ERROR, "Cannot locate a core keyboard device.\n");
|
||||
return FALSE;
|
||||
if (!xf86Info.allowEmptyInput) {
|
||||
/* This shouldn't happen. */
|
||||
xf86Msg(X_ERROR, "Cannot locate a core keyboard device.\n");
|
||||
return FALSE;
|
||||
} else {
|
||||
xf86Msg(X_INFO, "Cannot locate a core keyboard device.\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (pointerMsg) {
|
||||
xf86Msg(X_DEFAULT, "The core pointer device wasn't specified "
|
||||
"explicitly in the layout.\n"
|
||||
"\tUsing the %s.\n", pointerMsg);
|
||||
if (implicitLayout)
|
||||
xf86Msg(X_DEFAULT, "No Layout section. Using the %s.\n",
|
||||
pointerMsg);
|
||||
else
|
||||
xf86Msg(X_DEFAULT, "The core pointer device wasn't specified "
|
||||
"explicitly in the layout.\n"
|
||||
"\tUsing the %s.\n", pointerMsg);
|
||||
}
|
||||
|
||||
if (keyboardMsg) {
|
||||
xf86Msg(X_DEFAULT, "The core keyboard device wasn't specified "
|
||||
"explicitly in the layout.\n"
|
||||
"\tUsing the %s.\n", keyboardMsg);
|
||||
if (implicitLayout)
|
||||
xf86Msg(X_DEFAULT, "No Layout section. Using the %s.\n",
|
||||
keyboardMsg);
|
||||
else
|
||||
xf86Msg(X_DEFAULT, "The core keyboard device wasn't specified "
|
||||
"explicitly in the layout.\n"
|
||||
"\tUsing the %s.\n", keyboardMsg);
|
||||
}
|
||||
|
||||
if (xf86Info.allowEmptyInput && !(foundPointer && foundKeyboard)) {
|
||||
xf86Msg(X_INFO, "The server relies on HAL to provide the list of "
|
||||
"input devices.\n\tIf no devices become available, "
|
||||
"reconfigure HAL or disable AllowEmptyInput.\n");
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
@ -2457,26 +2479,8 @@ addDefaultModes(MonPtr monitorp)
|
|||
}
|
||||
|
||||
static void
|
||||
checkInput(serverLayoutPtr layout) {
|
||||
if (!xf86Info.allowEmptyInput)
|
||||
checkCoreInputDevices(layout, FALSE);
|
||||
else
|
||||
{
|
||||
xf86Msg(X_INFO, "AllowEmptyInput is on.\n"
|
||||
"\tThe server relies on HAL to provide the list of input "
|
||||
"devices.\n\tIf no devices become available, reconfigure "
|
||||
"HAL.\n");
|
||||
if (!layout->inputs || !*layout->inputs)
|
||||
{
|
||||
/* No input device specified in ServerLayout. */
|
||||
if (xf86configptr->conf_input_lst &&
|
||||
xf86configptr->conf_input_lst->inp_identifier)
|
||||
xf86Msg(X_WARNING, "Input devices specified in xorg.conf, but"
|
||||
" not referenced in ServerLayout.\n\tThese devices"
|
||||
" will NOT be available.\n");
|
||||
}
|
||||
|
||||
}
|
||||
checkInput(serverLayoutPtr layout, Bool implicit_layout) {
|
||||
checkCoreInputDevices(layout, implicit_layout);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -2490,6 +2494,7 @@ xf86HandleConfigFile(Bool autoconfig)
|
|||
MessageType from = X_DEFAULT;
|
||||
char *scanptr;
|
||||
Bool singlecard = 0;
|
||||
Bool implicit_layout = FALSE;
|
||||
|
||||
if (!autoconfig) {
|
||||
if (getuid() == 0)
|
||||
|
@ -2542,6 +2547,7 @@ xf86HandleConfigFile(Bool autoconfig)
|
|||
xf86Msg(X_ERROR, "Unable to determine the screen layout\n");
|
||||
return CONFIG_PARSE_ERROR;
|
||||
}
|
||||
implicit_layout = TRUE;
|
||||
} else {
|
||||
if (xf86configptr->conf_flags != NULL) {
|
||||
char *dfltlayout = NULL;
|
||||
|
@ -2599,7 +2605,7 @@ xf86HandleConfigFile(Bool autoconfig)
|
|||
configDRI(xf86configptr->conf_dri);
|
||||
#endif
|
||||
|
||||
checkInput(&xf86ConfigLayout);
|
||||
checkInput(&xf86ConfigLayout, implicit_layout);
|
||||
|
||||
/*
|
||||
* Handle some command line options that can override some of the
|
||||
|
|
Loading…
Reference in New Issue
Block a user