diff options
author | marha <marha@users.sourceforge.net> | 2009-09-09 05:23:48 +0000 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2009-09-09 05:23:48 +0000 |
commit | 81f91c615982e50bb62708201569c33a3cd3d973 (patch) | |
tree | 4f32ecc48a3b7b5e76642f3792338263c53879bd /xorg-server/xkb/xkbInit.c | |
parent | b571a562410f565af2bdde52d9f7f9a23ffae04f (diff) | |
parent | a915739887477b28d924ecc8417ee107d125bd6c (diff) | |
download | vcxsrv-81f91c615982e50bb62708201569c33a3cd3d973.tar.gz vcxsrv-81f91c615982e50bb62708201569c33a3cd3d973.tar.bz2 vcxsrv-81f91c615982e50bb62708201569c33a3cd3d973.zip |
svn merge https://vcxsrv.svn.sourceforge.net/svnroot/vcxsrv/branches/released .
Diffstat (limited to 'xorg-server/xkb/xkbInit.c')
-rw-r--r-- | xorg-server/xkb/xkbInit.c | 613 |
1 files changed, 230 insertions, 383 deletions
diff --git a/xorg-server/xkb/xkbInit.c b/xorg-server/xkb/xkbInit.c index a2993b6cd..7e0a8a90a 100644 --- a/xorg-server/xkb/xkbInit.c +++ b/xorg-server/xkb/xkbInit.c @@ -37,7 +37,6 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include <ctype.h> #include <unistd.h> #include <math.h> -#define NEED_EVENTS 1 #include <X11/X.h> #include <X11/Xproto.h> #include <X11/keysym.h> @@ -86,30 +85,6 @@ typedef struct _SrvXkmInfo { /***====================================================================***/ -#ifndef XKB_BASE_DIRECTORY -#define XKB_BASE_DIRECTORY "xkbdata" -#endif -#ifndef XKB_BIN_DIRECTORY -#define XKB_BIN_DIRECTORY "." -#endif -#ifndef XKB_DFLT_RULES_FILE -#define XKB_DFLT_RULES_FILE "base" -#endif -#ifndef XKB_DFLT_KB_LAYOUT -#define XKB_DFLT_KB_LAYOUT "us" -#endif -#ifndef XKB_DFLT_KB_MODEL -#define XKB_DFLT_KB_MODEL "dflt" -#endif -#ifndef XKB_DFLT_KB_VARIANT -#define XKB_DFLT_KB_VARIANT NULL -#endif -#ifndef XKB_DFLT_KB_OPTIONS -#define XKB_DFLT_KB_OPTIONS NULL -#endif -#ifndef XKB_DFLT_DISABLED -#define XKB_DFLT_DISABLED True -#endif #ifndef XKB_DFLT_RULES_PROP #define XKB_DFLT_RULES_PROP True #endif @@ -118,37 +93,65 @@ const char * XkbBaseDirectory= XKB_BASE_DIRECTORY; const char * XkbBinDirectory= XKB_BIN_DIRECTORY; static int XkbWantAccessX= 0; -static Bool rulesDefined= False; -static char * XkbRulesFile= NULL; +static char * XkbRulesDflt= NULL; static char * XkbModelDflt= NULL; static char * XkbLayoutDflt= NULL; static char * XkbVariantDflt= NULL; static char * XkbOptionsDflt= NULL; +static char * XkbRulesUsed= NULL; static char * XkbModelUsed= NULL; static char * XkbLayoutUsed= NULL; static char * XkbVariantUsed= NULL; static char * XkbOptionsUsed= NULL; -static XkbDescPtr xkb_cached_map = NULL; +static XkbDescPtr xkb_cached_map = NULL; -_X_EXPORT Bool noXkbExtension= XKB_DFLT_DISABLED; static Bool XkbWantRulesProp= XKB_DFLT_RULES_PROP; /***====================================================================***/ -static char * -XkbGetRulesDflts(XkbRF_VarDefsPtr defs) +/** + * Get the current default XKB rules. + * Caller must free the data in rmlvo. + */ +void +XkbGetRulesDflts(XkbRMLVOSet *rmlvo) { - if (XkbModelDflt) defs->model= XkbModelDflt; - else defs->model= XKB_DFLT_KB_MODEL; - if (XkbLayoutDflt) defs->layout= XkbLayoutDflt; - else defs->layout= XKB_DFLT_KB_LAYOUT; - if (XkbVariantDflt) defs->variant= XkbVariantDflt; - else defs->variant= XKB_DFLT_KB_VARIANT; - if (XkbOptionsDflt) defs->options= XkbOptionsDflt; - else defs->options= XKB_DFLT_KB_OPTIONS; - return (rulesDefined?XkbRulesFile:XKB_DFLT_RULES_FILE); + if (XkbRulesDflt) rmlvo->rules = XkbRulesDflt; + else rmlvo->rules = XKB_DFLT_RULES; + if (XkbModelDflt) rmlvo->model= XkbModelDflt; + else rmlvo->model= XKB_DFLT_MODEL; + if (XkbLayoutDflt) rmlvo->layout= XkbLayoutDflt; + else rmlvo->layout= XKB_DFLT_LAYOUT; + if (XkbVariantDflt) rmlvo->variant= XkbVariantDflt; + else rmlvo->variant= XKB_DFLT_VARIANT; + if (XkbOptionsDflt) rmlvo->options= XkbOptionsDflt; + else rmlvo->options= XKB_DFLT_OPTIONS; + + rmlvo->rules = strdup(rmlvo->rules); + rmlvo->model = strdup(rmlvo->model); + rmlvo->layout = strdup(rmlvo->layout); + rmlvo->variant = strdup(rmlvo->variant); + rmlvo->options = strdup(rmlvo->options); +} + +void +XkbFreeRMLVOSet(XkbRMLVOSet *rmlvo, Bool freeRMLVO) +{ + if (!rmlvo) + return; + + xfree(rmlvo->rules); + xfree(rmlvo->model); + xfree(rmlvo->layout); + xfree(rmlvo->variant); + xfree(rmlvo->options); + + if (freeRMLVO) + xfree(rmlvo); + else + memset(rmlvo, 0, sizeof(XkbRMLVOSet)); } static Bool @@ -158,9 +161,7 @@ int len,out; Atom name; char * pval; - if (rulesDefined && (!XkbRulesFile)) - return False; - len= (XkbRulesFile?strlen(XkbRulesFile):strlen(XKB_DFLT_RULES_FILE)); + len= (XkbRulesUsed?strlen(XkbRulesUsed):0); len+= (XkbModelUsed?strlen(XkbModelUsed):0); len+= (XkbLayoutUsed?strlen(XkbLayoutUsed):0); len+= (XkbVariantUsed?strlen(XkbVariantUsed):0); @@ -182,12 +183,9 @@ char * pval; return True; } out= 0; - if (XkbRulesFile) { - strcpy(&pval[out],XkbRulesFile); - out+= strlen(XkbRulesFile); - } else { - strcpy(&pval[out],XKB_DFLT_RULES_FILE); - out+= strlen(XKB_DFLT_RULES_FILE); + if (XkbRulesUsed) { + strcpy(&pval[out],XkbRulesUsed); + out+= strlen(XkbRulesUsed); } pval[out++]= '\0'; if (XkbModelUsed) { @@ -221,93 +219,93 @@ char * pval; } static void -XkbSetRulesUsed(XkbRF_VarDefsPtr defs) +XkbSetRulesUsed(XkbRMLVOSet *rmlvo) { + if (XkbRulesUsed) + xfree(XkbRulesUsed); + XkbRulesUsed= (rmlvo->rules?_XkbDupString(rmlvo->rules):NULL); if (XkbModelUsed) - _XkbFree(XkbModelUsed); - XkbModelUsed= (defs->model?_XkbDupString(defs->model):NULL); + xfree(XkbModelUsed); + XkbModelUsed= (rmlvo->model?_XkbDupString(rmlvo->model):NULL); if (XkbLayoutUsed) - _XkbFree(XkbLayoutUsed); - XkbLayoutUsed= (defs->layout?_XkbDupString(defs->layout):NULL); + xfree(XkbLayoutUsed); + XkbLayoutUsed= (rmlvo->layout?_XkbDupString(rmlvo->layout):NULL); if (XkbVariantUsed) - _XkbFree(XkbVariantUsed); - XkbVariantUsed= (defs->variant?_XkbDupString(defs->variant):NULL); + xfree(XkbVariantUsed); + XkbVariantUsed= (rmlvo->variant?_XkbDupString(rmlvo->variant):NULL); if (XkbOptionsUsed) - _XkbFree(XkbOptionsUsed); - XkbOptionsUsed= (defs->options?_XkbDupString(defs->options):NULL); + xfree(XkbOptionsUsed); + XkbOptionsUsed= (rmlvo->options?_XkbDupString(rmlvo->options):NULL); if (XkbWantRulesProp) QueueWorkProc(XkbWriteRulesProp,NULL,NULL); return; } -/** - * Set the default RMLVO for the next device to be initialised. - * If a parameter is NULL, the previous setting will be used. Use empty - * strings if you want to delete a previous setting. - * - * If @rulesFile is NULL and no previous @rulesFile has been set, the - * built-in default is chosen as default. - */ -_X_EXPORT void -XkbSetRulesDflts(char *rulesFile,char *model,char *layout, - char *variant,char *options) +void +XkbSetRulesDflts(XkbRMLVOSet *rmlvo) { - if (!rulesFile && !XkbRulesFile) - { - LogMessage(X_WARNING, "[xkb] No rule given, and no previous rule " - "defined. Defaulting to '%s'.\n", - XKB_DFLT_RULES_FILE); - rulesFile = XKB_DFLT_RULES_FILE; + if (rmlvo->rules) { + if (XkbRulesDflt) + xfree(XkbRulesDflt); + XkbRulesDflt= _XkbDupString(rmlvo->rules); } - - if (rulesFile) { - if (XkbRulesFile) - _XkbFree(XkbRulesFile); - XkbRulesFile= _XkbDupString(rulesFile); - rulesDefined= True; - } - - if (model) { + if (rmlvo->model) { if (XkbModelDflt) - _XkbFree(XkbModelDflt); - XkbModelDflt= _XkbDupString(model); + xfree(XkbModelDflt); + XkbModelDflt= _XkbDupString(rmlvo->model); } - if (layout) { + if (rmlvo->layout) { if (XkbLayoutDflt) - _XkbFree(XkbLayoutDflt); - XkbLayoutDflt= _XkbDupString(layout); + xfree(XkbLayoutDflt); + XkbLayoutDflt= _XkbDupString(rmlvo->layout); } - if (variant) { + if (rmlvo->variant) { if (XkbVariantDflt) - _XkbFree(XkbVariantDflt); - XkbVariantDflt= _XkbDupString(variant); + xfree(XkbVariantDflt); + XkbVariantDflt= _XkbDupString(rmlvo->variant); } - if (options) { + if (rmlvo->options) { if (XkbOptionsDflt) - _XkbFree(XkbOptionsDflt); - XkbOptionsDflt= _XkbDupString(options); + xfree(XkbOptionsDflt); + XkbOptionsDflt= _XkbDupString(rmlvo->options); } return; } void -XkbDeleteRulesDflts() +XkbDeleteRulesDflts(void) { - _XkbFree(XkbRulesFile); - XkbRulesFile = NULL; - _XkbFree(XkbModelDflt); + xfree(XkbRulesDflt); + XkbRulesDflt = NULL; + xfree(XkbModelDflt); XkbModelDflt = NULL; - _XkbFree(XkbLayoutDflt); + xfree(XkbLayoutDflt); XkbLayoutDflt = NULL; - _XkbFree(XkbVariantDflt); + xfree(XkbVariantDflt); XkbVariantDflt = NULL; - _XkbFree(XkbOptionsDflt); + xfree(XkbOptionsDflt); XkbOptionsDflt = NULL; XkbFreeKeyboard(xkb_cached_map, XkbAllComponentsMask, True); xkb_cached_map = NULL; } +#define DIFFERS(a, b) (strcmp((a) ? (a) : "", (b) ? (b) : "") != 0) + +static Bool +XkbCompareUsedRMLVO(XkbRMLVOSet *rmlvo) +{ + if (DIFFERS(rmlvo->rules, XkbRulesUsed) || + DIFFERS(rmlvo->model, XkbModelUsed) || + DIFFERS(rmlvo->layout, XkbLayoutUsed) || + DIFFERS(rmlvo->variant, XkbVariantUsed) || + DIFFERS(rmlvo->options, XkbOptionsUsed)) + return FALSE; + return TRUE; +} + +#undef DIFFERS + /***====================================================================***/ #include "xkbDflts.h" @@ -493,292 +491,151 @@ XkbControlsPtr ctrls; return Success; } -void -XkbInitDevice(DeviceIntPtr pXDev) +_X_EXPORT Bool +InitKeyboardDeviceStruct(DeviceIntPtr dev, XkbRMLVOSet *rmlvo, + BellProcPtr bell_func, KbdCtrlProcPtr ctrl_func) { -int i; -XkbSrvInfoPtr xkbi; -XkbChangesRec changes; -unsigned check; -XkbEventCauseRec cause; - - bzero(&changes,sizeof(XkbChangesRec)); - pXDev->key->xkbInfo= xkbi= _XkbTypedCalloc(1,XkbSrvInfoRec); - if ( xkbi ) { - XkbDescPtr xkb; + int i; + unsigned int check; + XkbSrvInfoPtr xkbi; + XkbDescPtr xkb; + XkbSrvLedInfoPtr sli; + XkbChangesRec changes; + XkbEventCauseRec cause; + XkbRMLVOSet rmlvo_dflts = { NULL }; + + if (dev->key || dev->kbdfeed) + return FALSE; + + if (!rmlvo) + { + rmlvo = &rmlvo_dflts; + XkbGetRulesDflts(rmlvo); + } - if (xkb_cached_map) { - xkbi->desc = xkb_cached_map; - xkb_cached_map = NULL; - } - else { - xkbi->desc= XkbAllocKeyboard(); - if (!xkbi->desc) - FatalError("Couldn't allocate keyboard description\n"); - xkbi->desc->min_key_code = pXDev->key->curKeySyms.minKeyCode; - xkbi->desc->max_key_code = pXDev->key->curKeySyms.maxKeyCode; + + memset(&changes, 0, sizeof(changes)); + XkbSetCauseUnknown(&cause); + + dev->key = xcalloc(1, sizeof(*dev->key)); + if (!dev->key) { + ErrorF("XKB: Failed to allocate key class\n"); + return False; + } + dev->key->sourceid = dev->id; + + dev->kbdfeed = xcalloc(1, sizeof(*dev->kbdfeed)); + if (!dev->kbdfeed) { + ErrorF("XKB: Failed to allocate key feedback class\n"); + goto unwind_key; + } + + xkbi = xcalloc(1, sizeof(*xkbi)); + if (!xkbi) { + ErrorF("XKB: Failed to allocate XKB info\n"); + goto unwind_kbdfeed; + } + dev->key->xkbInfo = xkbi; + + if (xkb_cached_map && !XkbCompareUsedRMLVO(rmlvo)) { + XkbFreeKeyboard(xkb_cached_map, XkbAllComponentsMask, True); + xkb_cached_map = NULL; + } + + if (xkb_cached_map) + LogMessageVerb(X_INFO, 4, "XKB: Reusing cached keymap\n"); + else { + xkb_cached_map = XkbCompileKeymap(dev, rmlvo); + if (!xkb_cached_map) { + ErrorF("XKB: Failed to compile keymap\n"); + goto unwind_info; } - xkb= xkbi->desc; - if (xkb->min_key_code == 0) - xkb->min_key_code = pXDev->key->curKeySyms.minKeyCode; - if (xkb->max_key_code == 0) - xkb->max_key_code = pXDev->key->curKeySyms.maxKeyCode; - if ((pXDev->key->curKeySyms.minKeyCode!=xkbi->desc->min_key_code)|| - (pXDev->key->curKeySyms.maxKeyCode!=xkbi->desc->max_key_code)) { - /* 12/9/95 (ef) -- XXX! Maybe we should try to fix up one or */ - /* the other here, but for now just complain */ - /* can't just update the core range without */ - /* reallocating the KeySymsRec (pain) */ - ErrorF("[xkb] Internal Error!! XKB and core keymap have different range\n"); - } - if (XkbAllocClientMap(xkb,XkbAllClientInfoMask,0)!=Success) - FatalError("Couldn't allocate client map in XkbInitDevice\n"); - i= XkbNumKeys(xkb)/3+1; - if (XkbAllocServerMap(xkb,XkbAllServerInfoMask,i)!=Success) - FatalError("Couldn't allocate server map in XkbInitDevice\n"); - - xkbi->dfltPtrDelta=1; - xkbi->device = pXDev; - - XkbInitSemantics(xkb); - XkbInitNames(xkbi); - XkbInitRadioGroups(xkbi); - - /* 12/31/94 (ef) -- XXX! Should check if state loaded from file */ - bzero(&xkbi->state,sizeof(XkbStateRec)); - - XkbInitControls(pXDev,xkbi); - - if (xkb->defined & XkmSymbolsMask) - memcpy(pXDev->key->modifierMap, xkb->map->modmap, - xkb->max_key_code + 1); - else - memcpy(xkb->map->modmap, pXDev->key->modifierMap, - xkb->max_key_code + 1); - - XkbInitIndicatorMap(xkbi); - - XkbDDXInitDevice(pXDev); - - if (xkb->defined & XkmSymbolsMask) - XkbUpdateCoreDescription(pXDev, True); - else - XkbUpdateKeyTypesFromCore(pXDev, xkb->min_key_code, - XkbNumKeys(xkb), &changes); - - XkbSetCauseUnknown(&cause); - XkbUpdateActions(pXDev,xkb->min_key_code, XkbNumKeys(xkb),&changes, - &check,&cause); - /* For sanity. The first time the connection - * is opened, the client side min and max are set - * using QueryMinMaxKeyCodes() which grabs them - * from pXDev. - */ - pXDev->key->curKeySyms.minKeyCode = xkb->min_key_code; - pXDev->key->curKeySyms.maxKeyCode = xkb->max_key_code; } - return; -} -#if MAP_LENGTH > XkbMaxKeyCount -#undef XkbMaxKeyCount -#define XkbMaxKeyCount MAP_LENGTH -#endif + xkb = XkbAllocKeyboard(); + if (!xkb) { + ErrorF("XKB: Failed to allocate keyboard description\n"); + goto unwind_info; + } -_X_EXPORT Bool -XkbInitKeyboardDeviceStruct( - DeviceIntPtr dev, - XkbComponentNamesPtr names, - KeySymsPtr pSymsIn, - CARD8 pModsIn[], - void (*bellProc)( - int /*percent*/, - DeviceIntPtr /*device*/, - pointer /*ctrl*/, - int), - void (*ctrlProc)( - DeviceIntPtr /*device*/, - KeybdCtrl * /*ctrl*/)) -{ -KeySymsRec tmpSyms,*pSyms; -CARD8 tmpMods[XkbMaxLegalKeyCode+1],*pMods; -char name[PATH_MAX],*rules; -Bool ok=False; -XkbRF_VarDefsRec defs; -XkbDescPtr xkb; - - if ((dev->key!=NULL)||(dev->kbdfeed!=NULL)) - return False; - pSyms= pSymsIn; - pMods= pModsIn; - bzero(&defs,sizeof(XkbRF_VarDefsRec)); - rules= XkbGetRulesDflts(&defs); - - /* - * The strings are duplicated because it is not guaranteed that - * they are allocated, or that they are allocated for every server - * generation. Eventually they will be freed at the end of this - * function. - */ - names->keymap = NULL; - if (names->keycodes) names->keycodes = _XkbDupString(names->keycodes); - if (names->types) names->types = _XkbDupString(names->types); - if (names->compat) names->compat = _XkbDupString(names->compat); - if (names->geometry) names->geometry = _XkbDupString(names->geometry); - if (names->symbols) names->symbols = _XkbDupString(names->symbols); - - if (defs.model && defs.layout && rules) { - XkbComponentNamesRec rNames; - bzero(&rNames,sizeof(XkbComponentNamesRec)); - if (XkbDDXNamesFromRules(dev,rules,&defs,&rNames)) { - if (rNames.keycodes) { - if (!names->keycodes) - names->keycodes = rNames.keycodes; - else - _XkbFree(rNames.keycodes); - } - if (rNames.types) { - if (!names->types) - names->types = rNames.types; - else _XkbFree(rNames.types); - } - if (rNames.compat) { - if (!names->compat) - names->compat = rNames.compat; - else _XkbFree(rNames.compat); - } - if (rNames.symbols) { - if (!names->symbols) - names->symbols = rNames.symbols; - else _XkbFree(rNames.symbols); - } - if (rNames.geometry) { - if (!names->geometry) - names->geometry = rNames.geometry; - else _XkbFree(rNames.geometry); - } - XkbSetRulesUsed(&defs); - } + if (!XkbCopyKeymap(xkb, xkb_cached_map)) { + ErrorF("XKB: Failed to copy keymap\n"); + goto unwind_desc; } + xkb->defined = xkb_cached_map->defined; + xkb->flags = xkb_cached_map->flags; + xkb->device_spec = xkb_cached_map->device_spec; + xkbi->desc = xkb; - ok = (Bool) XkbDDXLoadKeymapByNames(dev,names,XkmAllIndicesMask,0, - &xkb,name,PATH_MAX); + if (xkb->min_key_code == 0) + xkb->min_key_code = 8; + if (xkb->max_key_code == 0) + xkb->max_key_code = 255; - if (ok && (xkb!=NULL)) { - KeyCode minKC,maxKC; + i = XkbNumKeys(xkb) / 3 + 1; + if (XkbAllocClientMap(xkb, XkbAllClientInfoMask, 0) != Success) + goto unwind_desc; + if (XkbAllocServerMap(xkb, XkbAllServerInfoMask, i) != Success) + goto unwind_desc; - minKC= xkb->min_key_code; - maxKC= xkb->max_key_code; - if (XkbIsLegalKeycode(minKC)&&XkbIsLegalKeycode(maxKC)&&(minKC<=maxKC)&& - ((minKC!=pSyms->minKeyCode)||(maxKC!=pSyms->maxKeyCode))) { - if (xkb->map!=NULL) { - KeySym *inSym,*outSym; - int width= pSymsIn->mapWidth; + xkbi->dfltPtrDelta = 1; + xkbi->device = dev; - tmpSyms.minKeyCode= minKC; - tmpSyms.maxKeyCode= maxKC; + XkbInitSemantics(xkb); + XkbInitNames(xkbi); + XkbInitRadioGroups(xkbi); - if (minKC<pSymsIn->minKeyCode) - minKC= pSymsIn->minKeyCode; - if (maxKC>pSymsIn->maxKeyCode) - maxKC= pSymsIn->maxKeyCode; + XkbInitControls(dev, xkbi); - tmpSyms.mapWidth= width; - tmpSyms.map= _XkbTypedCalloc(width*XkbNumKeys(xkb),KeySym); - inSym= &pSymsIn->map[(minKC-pSymsIn->minKeyCode)*width]; - outSym= &tmpSyms.map[(minKC-tmpSyms.minKeyCode)*width]; - memcpy(outSym,inSym,((maxKC-minKC+1)*width)*sizeof(KeySym)); - pSyms= &tmpSyms; - } - if ((xkb->map!=NULL)&&(xkb->map->modmap!=NULL)) { - bzero(tmpMods,XkbMaxKeyCount); - memcpy(tmpMods,xkb->map->modmap,maxKC+1); - pMods= tmpMods; - } - } - /* Store the map here so we can pick it back up in XkbInitDevice. - * Sigh. */ - xkb_cached_map = xkb; - } - else { - LogMessage(X_WARNING, "Couldn't load XKB keymap, falling back to pre-XKB keymap\n"); - } - ok= InitKeyboardDeviceStruct((DevicePtr)dev,pSyms,pMods,bellProc,ctrlProc); - xkb_cached_map = NULL; - if ((pSyms==&tmpSyms)&&(pSyms->map!=NULL)) { - _XkbFree(pSyms->map); - pSyms->map= NULL; - } - - if (names->keycodes) _XkbFree(names->keycodes); - names->keycodes = NULL; - if (names->types) _XkbFree(names->types); - names->types = NULL; - if (names->compat) _XkbFree(names->compat); - names->compat = NULL; - if (names->geometry) _XkbFree(names->geometry); - names->geometry = NULL; - if (names->symbols) _XkbFree(names->symbols); - names->symbols = NULL; - - return ok; -} + XkbInitIndicatorMap(xkbi); -/***====================================================================***/ + XkbUpdateActions(dev, xkb->min_key_code, XkbNumKeys(xkb), &changes, + &check, &cause); - /* - * InitKeyClassDeviceStruct initializes the key class before it - * initializes the keyboard feedback class for a device. - * UpdateActions can't set up the correct autorepeat for keyboard - * initialization because the keyboard feedback isn't created yet. - * Instead, UpdateActions notes the "correct" autorepeat in the - * SrvInfo structure and InitKbdFeedbackClass calls UpdateAutoRepeat - * to apply the computed autorepeat once the feedback class exists. - * - * DIX will apply the changed autorepeat, so there's no need to - * do so here. This function returns True if both RepeatKeys and - * the core protocol autorepeat ctrls are set (i.e. should use - * software autorepeat), false otherwise. - * - * This function also computes the autorepeat accelerators for the - * default indicator feedback. - */ -int -XkbFinishDeviceInit(DeviceIntPtr pXDev) -{ -XkbSrvInfoPtr xkbi; -XkbDescPtr xkb; -int softRepeat; -XkbSrvLedInfoPtr sli; + InitFocusClassDeviceStruct(dev); - xkbi = NULL; - if (pXDev && pXDev->key && pXDev->key->xkbInfo && pXDev->kbdfeed) { - xkbi= pXDev->key->xkbInfo; - xkb= xkbi->desc; - /* If we come from DeepCopyDeviceClasses, the CtrlProc was already set - * to XkbDDXKeybdCtrlProc, overwriting it leads to happy recursion. - */ - if (pXDev->kbdfeed && pXDev->kbdfeed->CtrlProc != XkbDDXKeybdCtrlProc) { - xkbi->kbdProc= pXDev->kbdfeed->CtrlProc; - pXDev->kbdfeed->CtrlProc= XkbDDXKeybdCtrlProc; - } - if (pXDev->kbdfeed->ctrl.autoRepeat) - xkb->ctrls->enabled_ctrls|= XkbRepeatKeysMask; - softRepeat= (xkb->ctrls->enabled_ctrls&XkbRepeatKeysMask)!=0; - if (pXDev->kbdfeed) { - memcpy(pXDev->kbdfeed->ctrl.autoRepeats, - xkb->ctrls->per_key_repeat,XkbPerKeyBitArraySize); - softRepeat= softRepeat&&pXDev->kbdfeed->ctrl.autoRepeat; - } - } - else softRepeat= 0; - sli= XkbFindSrvLedInfo(pXDev,XkbDfltXIClass,XkbDfltXIId,0); - if (sli && xkbi) - XkbCheckIndicatorMaps(xkbi->device,sli,XkbAllIndicatorsMask); - else DebugF("[xkb] No indicator feedback in XkbFinishInit (shouldn't happen)!\n"); - return softRepeat; + xkbi->kbdProc = ctrl_func; + dev->kbdfeed->BellProc = bell_func; + dev->kbdfeed->CtrlProc = XkbDDXKeybdCtrlProc; + + dev->kbdfeed->ctrl = defaultKeyboardControl; + if (dev->kbdfeed->ctrl.autoRepeat) + xkb->ctrls->enabled_ctrls |= XkbRepeatKeysMask; + + memcpy(dev->kbdfeed->ctrl.autoRepeats, xkb->ctrls->per_key_repeat, + XkbPerKeyBitArraySize); + + sli = XkbFindSrvLedInfo(dev, XkbDfltXIClass, XkbDfltXIId, 0); + if (sli) + XkbCheckIndicatorMaps(dev, sli, XkbAllIndicatorsMask); + else + DebugF("XKB: No indicator feedback in XkbFinishInit!\n"); + + dev->kbdfeed->CtrlProc(dev,&dev->kbdfeed->ctrl); + + XkbSetRulesDflts(rmlvo); + XkbSetRulesUsed(rmlvo); + XkbFreeRMLVOSet(&rmlvo_dflts, FALSE); + + return TRUE; + +unwind_desc: + XkbFreeKeyboard(xkb, 0, TRUE); +unwind_info: + xfree(xkbi); + dev->key->xkbInfo = NULL; +unwind_kbdfeed: + xfree(dev->kbdfeed); + dev->kbdfeed = NULL; +unwind_key: + xfree(dev->key); + dev->key = NULL; + return FALSE; } + +/***====================================================================***/ + /* * Be very careful about what does and doesn't get freed by this * function. To reduce fragmentation, XkbInitDevice allocates a @@ -790,7 +647,7 @@ void XkbFreeInfo(XkbSrvInfoPtr xkbi) { if (xkbi->radioGroups) { - _XkbFree(xkbi->radioGroups); + xfree(xkbi->radioGroups); xkbi->radioGroups= NULL; } if (xkbi->mouseKeyTimer) { @@ -822,7 +679,7 @@ XkbFreeInfo(XkbSrvInfoPtr xkbi) XkbFreeKeyboard(xkbi->desc,XkbAllComponentsMask,True); xkbi->desc= NULL; } - _XkbFree(xkbi); + xfree(xkbi); return; } @@ -839,15 +696,7 @@ extern unsigned char XkbDfltAccessXOptions; int XkbProcessArguments(int argc,char *argv[],int i) { - if (strcmp(argv[i],"-kb")==0) { - noXkbExtension= True; - return 1; - } - else if (strcmp(argv[i],"+kb")==0) { - noXkbExtension= False; - return 1; - } - else if (strncmp(argv[i], "-xkbdir", 7) == 0) { + if (strncmp(argv[i], "-xkbdir", 7) == 0) { if(++i < argc) { #if !defined(WIN32) && !defined(__CYGWIN__) if (getuid() != geteuid()) { @@ -925,8 +774,6 @@ XkbProcessArguments(int argc,char *argv[],int i) void XkbUseMsg(void) { - ErrorF("-kb disable the X Keyboard Extension\n"); - ErrorF("+kb enable the X Keyboard Extension\n"); ErrorF("[+-]accessx [ timeout [ timeout_mask [ feedback [ options_mask] ] ] ]\n"); ErrorF(" enable/disable accessx key sequences\n"); ErrorF("-ardelay set XKB autorepeat delay\n"); |