From fbd776894658e7afb2c55dc8582b2a3efab78a3c Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Sat, 16 Feb 2008 20:01:18 +0200 Subject: XKB: Ditch XkbFileInfo Sorry about the megacommit, but this touches on a lot of stuff. Get rid of XkbFileInfo, which was pretty seriously redundant, and move the only useful thing it had (defined) into XkbDescRec. defined will be removed pretty soon anyway. Is the compat map pointer non-NULL? Then you have a compat map, congratulations! Anyhow, I digress. All functions that took an XkbFileInfoPtr now take an XkbDescPtr, _except_ XkmReadFile, which returns an XkbDescPtr *, because people want to deal in XkbDescPtrs, not XkbDescRecs. --- include/xkbfile.h | 45 ++++++--------- include/xkbsrv.h | 2 +- include/xkbstr.h | 1 + xkb/ddxLoad.c | 14 ++--- xkb/xkb.c | 89 +++++++++++++++-------------- xkb/xkbActions.c | 4 +- xkb/xkbInit.c | 163 +++++++++++++++++++++--------------------------------- xkb/xkbfmisc.c | 98 +++----------------------------- xkb/xkbout.c | 46 ++++++--------- xkb/xkmread.c | 161 +++++++---------------------------------------------- 10 files changed, 178 insertions(+), 445 deletions(-) diff --git a/include/xkbfile.h b/include/xkbfile.h index e90d7668e..0a6cb18b9 100644 --- a/include/xkbfile.h +++ b/include/xkbfile.h @@ -37,15 +37,9 @@ #define XkbMapDefined (1<<0) #define XkbStateDefined (1<<1) -typedef struct _XkbFileInfo { - unsigned type; - unsigned defined; - XkbDescPtr xkb; -} XkbFileInfo,*XkbFileInfoPtr; - typedef void (*XkbFileAddOnFunc)( FILE * /* file */, - XkbFileInfo * /* result */, + XkbDescPtr /* result */, Bool /* topLevel */, Bool /* showImplicit */, int /* fileSection */, @@ -277,12 +271,6 @@ extern unsigned XkbConvertXkbComponents( unsigned /* orig */ ); -extern Bool XkbDetermineFileType( - XkbFileInfo * /* xkb */, - int /* format */, - int * /* opts_missing */ -); - extern Bool XkbNameMatchesPattern( char * /* name */, char * /* pattern */ @@ -292,7 +280,7 @@ extern Bool XkbNameMatchesPattern( extern Bool XkbWriteXKBKeycodes( FILE * /* file */, - XkbFileInfo * /* result */, + XkbDescPtr /* result */, Bool /* topLevel */, Bool /* showImplicit */, XkbFileAddOnFunc /* addOn */, @@ -301,7 +289,7 @@ extern Bool XkbWriteXKBKeycodes( extern Bool XkbWriteXKBKeyTypes( FILE * /* file */, - XkbFileInfo * /* result */, + XkbDescPtr /* result */, Bool /* topLevel */, Bool /* showImplicit */, XkbFileAddOnFunc /* addOn */, @@ -310,7 +298,7 @@ extern Bool XkbWriteXKBKeyTypes( extern Bool XkbWriteXKBCompatMap( FILE * /* file */, - XkbFileInfo * /* result */, + XkbDescPtr /* result */, Bool /* topLevel */, Bool /* showImplicit */, XkbFileAddOnFunc /* addOn */, @@ -319,7 +307,7 @@ extern Bool XkbWriteXKBCompatMap( extern Bool XkbWriteXKBSymbols( FILE * /* file */, - XkbFileInfo * /* result */, + XkbDescPtr /* result */, Bool /* topLevel */, Bool /* showImplicit */, XkbFileAddOnFunc /* addOn */, @@ -328,7 +316,7 @@ extern Bool XkbWriteXKBSymbols( extern Bool XkbWriteXKBGeometry( FILE * /* file */, - XkbFileInfo * /* result */, + XkbDescPtr /* result */, Bool /* topLevel */, Bool /* showImplicit */, XkbFileAddOnFunc /* addOn */, @@ -337,7 +325,7 @@ extern Bool XkbWriteXKBGeometry( extern Bool XkbWriteXKBSemantics( FILE * /* file */, - XkbFileInfo * /* result */, + XkbDescPtr /* result */, Bool /* topLevel */, Bool /* showImplicit */, XkbFileAddOnFunc /* addOn */, @@ -346,7 +334,7 @@ extern Bool XkbWriteXKBSemantics( extern Bool XkbWriteXKBLayout( FILE * /* file */, - XkbFileInfo * /* result */, + XkbDescPtr /* result */, Bool /* topLevel */, Bool /* showImplicit */, XkbFileAddOnFunc /* addOn */, @@ -355,7 +343,7 @@ extern Bool XkbWriteXKBLayout( extern Bool XkbWriteXKBKeymap( FILE * /* file */, - XkbFileInfo * /* result */, + XkbDescPtr /* result */, Bool /* topLevel */, Bool /* showImplicit */, XkbFileAddOnFunc /* addOn */, @@ -364,7 +352,7 @@ extern Bool XkbWriteXKBKeymap( extern Bool XkbWriteXKBFile( FILE * /* file */, - XkbFileInfo * /* result */, + XkbDescPtr /* result */, Bool /* showImplicit */, XkbFileAddOnFunc /* addOn */, void * /* priv */ @@ -373,16 +361,16 @@ extern Bool XkbWriteXKBFile( extern Bool XkbWriteCFile( FILE * /* file */, char * /* name */, - XkbFileInfo * /* info */ + XkbDescPtr /* info */ ); extern Bool XkbWriteXKMFile( FILE * /* file */, - XkbFileInfo * /* result */ + XkbDescPtr /* result */ ); extern Bool XkbWriteToServer( - XkbFileInfo * /* result */ + XkbDescPtr /* result */ ); extern void XkbEnsureSafeMapName( @@ -398,8 +386,7 @@ extern Bool XkbWriteXKBKeymapForNames( ); extern Status XkbMergeFile( - XkbDescPtr /* xkb */, - XkbFileInfo /* finfo */ + XkbDescPtr /* xkb */ ); /***====================================================================***/ @@ -412,7 +399,7 @@ extern unsigned XkmReadFile( FILE * /* file */, unsigned /* need */, unsigned /* want */, - XkbFileInfo * /* result */ + XkbDescPtr * /* result */ ); #ifdef _XKMFORMAT_H_ @@ -433,7 +420,7 @@ extern xkmSectionInfo *XkmFindTOCEntry( extern Bool XkmReadFileSection( FILE * /* file */, xkmSectionInfo * /* toc */, - XkbFileInfo * /* result */, + XkbDescPtr /* result */, unsigned * /* loaded_rtrn */ ); diff --git a/include/xkbsrv.h b/include/xkbsrv.h index 60b0eb7e5..ef99e94e7 100644 --- a/include/xkbsrv.h +++ b/include/xkbsrv.h @@ -1005,7 +1005,7 @@ extern unsigned int XkbDDXLoadKeymapByNames( XkbComponentNamesPtr /* names */, unsigned int /* want */, unsigned int /* need */, - XkbFileInfoPtr /* finfoRtrn */, + XkbDescPtr * /* finfoRtrn */, char * /* keymapNameRtrn */, int /* keymapNameRtrnLen */ ); diff --git a/include/xkbstr.h b/include/xkbstr.h index f390c611c..214a5543c 100644 --- a/include/xkbstr.h +++ b/include/xkbstr.h @@ -418,6 +418,7 @@ typedef struct _XkbGeometry *XkbGeometryPtr; * Tie it all together into one big keyboard description */ typedef struct _XkbDesc { + unsigned int defined; unsigned short flags; unsigned short device_spec; KeyCode min_key_code; diff --git a/xkb/ddxLoad.c b/xkb/ddxLoad.c index 760119dc9..d80ce62b8 100644 --- a/xkb/ddxLoad.c +++ b/xkb/ddxLoad.c @@ -334,16 +334,16 @@ XkbDDXLoadKeymapByNames( DeviceIntPtr keybd, XkbComponentNamesPtr names, unsigned want, unsigned need, - XkbFileInfo * finfoRtrn, + XkbDescPtr * xkbRtrn, char * nameRtrn, int nameRtrnLen) { -XkbDescPtr xkb; +XkbDescPtr xkb; FILE * file; char fileName[PATH_MAX]; unsigned missing; - bzero(finfoRtrn,sizeof(XkbFileInfo)); + *xkbRtrn = NULL; if ((keybd==NULL)||(keybd->key==NULL)||(keybd->key->xkbInfo==NULL)) xkb= NULL; else xkb= keybd->key->xkbInfo->desc; @@ -353,7 +353,7 @@ unsigned missing; return 0; } else if (!XkbDDXCompileKeymapByNames(xkb,names,want,need, - nameRtrn,nameRtrnLen)){ + nameRtrn,nameRtrnLen)){ DebugF("Couldn't compile keymap file\n"); return 0; } @@ -362,15 +362,15 @@ unsigned missing; LogMessage(X_ERROR, "Couldn't open compiled keymap file %s\n",fileName); return 0; } - missing= XkmReadFile(file,need,want,finfoRtrn); - if (finfoRtrn->xkb==NULL) { + missing= XkmReadFile(file,need,want,xkbRtrn); + if (*xkbRtrn==NULL) { LogMessage(X_ERROR, "Error loading keymap %s\n",fileName); fclose(file); (void) unlink (fileName); return 0; } else if (xkbDebugFlags) { - DebugF("Loaded XKB keymap %s, defined=0x%x\n",fileName,finfoRtrn->defined); + DebugF("Loaded XKB keymap %s, defined=0x%x\n",fileName,(*xkbRtrn)->defined); } fclose(file); (void) unlink (fileName); diff --git a/xkb/xkb.c b/xkb/xkb.c index ea5189f2c..b0d2f0d3d 100644 --- a/xkb/xkb.c +++ b/xkb/xkb.c @@ -5109,7 +5109,6 @@ ProcXkbGetKbdByName(ClientPtr client) { DeviceIntPtr dev; DeviceIntPtr tmpd; - XkbFileInfo finfo; xkbGetKbdByNameReply rep; xkbGetMapReply mrep; xkbGetCompatMapReply crep; @@ -5117,7 +5116,7 @@ ProcXkbGetKbdByName(ClientPtr client) xkbGetNamesReply nrep; xkbGetGeometryReply grep; XkbComponentNamesRec names; - XkbDescPtr xkb; + XkbDescPtr xkb, new; unsigned char * str; char mapFile[PATH_MAX]; unsigned len; @@ -5194,35 +5193,35 @@ ProcXkbGetKbdByName(ClientPtr client) } /* We pass dev in here so we can get the old names out if needed. */ - rep.found = XkbDDXLoadKeymapByNames(dev,&names,fwant,fneed,&finfo, + rep.found = XkbDDXLoadKeymapByNames(dev,&names,fwant,fneed,&new, mapFile,PATH_MAX); rep.newKeyboard= False; rep.pad1= rep.pad2= rep.pad3= rep.pad4= 0; stuff->want|= stuff->need; - if (finfo.xkb==NULL) + if (new==NULL) rep.reported= 0; else { if (stuff->load) rep.loaded= True; if (stuff->load || - ((rep.reported&XkbGBN_SymbolsMask) && (finfo.xkb->compat))) { + ((rep.reported&XkbGBN_SymbolsMask) && (new->compat))) { XkbChangesRec changes; bzero(&changes,sizeof(changes)); - XkbUpdateDescActions(finfo.xkb, - finfo.xkb->min_key_code,XkbNumKeys(finfo.xkb), + XkbUpdateDescActions(new, + new->min_key_code,XkbNumKeys(new), &changes); } - if (finfo.xkb->map==NULL) + if (new->map==NULL) rep.reported&= ~(XkbGBN_SymbolsMask|XkbGBN_TypesMask); else if (rep.reported&(XkbGBN_SymbolsMask|XkbGBN_TypesMask)) { mrep.type= X_Reply; mrep.deviceID = dev->id; mrep.sequenceNumber= client->sequence; mrep.length = ((SIZEOF(xkbGetMapReply)-SIZEOF(xGenericReply))>>2); - mrep.minKeyCode = finfo.xkb->min_key_code; - mrep.maxKeyCode = finfo.xkb->max_key_code; + mrep.minKeyCode = new->min_key_code; + mrep.maxKeyCode = new->max_key_code; mrep.present = 0; mrep.totalSyms = mrep.totalActs = mrep.totalKeyBehaviors= mrep.totalKeyExplicit= @@ -5230,7 +5229,7 @@ ProcXkbGetKbdByName(ClientPtr client) if (rep.reported&(XkbGBN_TypesMask|XkbGBN_ClientSymbolsMask)) { mrep.present|= XkbKeyTypesMask; mrep.firstType = 0; - mrep.nTypes = mrep.totalTypes= finfo.xkb->map->num_types; + mrep.nTypes = mrep.totalTypes= new->map->num_types; } else { mrep.firstType = mrep.nTypes= 0; @@ -5238,8 +5237,8 @@ ProcXkbGetKbdByName(ClientPtr client) } if (rep.reported&XkbGBN_ClientSymbolsMask) { mrep.present|= (XkbKeySymsMask|XkbModifierMapMask); - mrep.firstKeySym = mrep.firstModMapKey= finfo.xkb->min_key_code; - mrep.nKeySyms = mrep.nModMapKeys= XkbNumKeys(finfo.xkb); + mrep.firstKeySym = mrep.firstModMapKey= new->min_key_code; + mrep.nKeySyms = mrep.nModMapKeys= XkbNumKeys(new); } else { mrep.firstKeySym= mrep.firstModMapKey= 0; @@ -5249,9 +5248,9 @@ ProcXkbGetKbdByName(ClientPtr client) mrep.present|= XkbAllServerInfoMask; mrep.virtualMods= ~0; mrep.firstKeyAct = mrep.firstKeyBehavior = - mrep.firstKeyExplicit = finfo.xkb->min_key_code; + mrep.firstKeyExplicit = new->min_key_code; mrep.nKeyActs = mrep.nKeyBehaviors = - mrep.nKeyExplicit = XkbNumKeys(finfo.xkb); + mrep.nKeyExplicit = XkbNumKeys(new); } else { mrep.virtualMods= 0; @@ -5259,10 +5258,10 @@ ProcXkbGetKbdByName(ClientPtr client) mrep.firstKeyExplicit = 0; mrep.nKeyActs= mrep.nKeyBehaviors= mrep.nKeyExplicit= 0; } - XkbComputeGetMapReplySize(finfo.xkb,&mrep); + XkbComputeGetMapReplySize(new,&mrep); rep.length+= SIZEOF(xGenericReply)/4+mrep.length; } - if (finfo.xkb->compat==NULL) + if (new->compat==NULL) rep.reported&= ~XkbGBN_CompatMapMask; else if (rep.reported&XkbGBN_CompatMapMask) { crep.type= X_Reply; @@ -5271,11 +5270,11 @@ ProcXkbGetKbdByName(ClientPtr client) crep.length= 0; crep.groups= XkbAllGroupsMask; crep.firstSI= 0; - crep.nSI= crep.nTotalSI= finfo.xkb->compat->num_si; - XkbComputeGetCompatMapReplySize(finfo.xkb->compat,&crep); + crep.nSI= crep.nTotalSI= new->compat->num_si; + XkbComputeGetCompatMapReplySize(new->compat,&crep); rep.length+= SIZEOF(xGenericReply)/4+crep.length; } - if (finfo.xkb->indicators==NULL) + if (new->indicators==NULL) rep.reported&= ~XkbGBN_IndicatorMapMask; else if (rep.reported&XkbGBN_IndicatorMapMask) { irep.type= X_Reply; @@ -5283,28 +5282,28 @@ ProcXkbGetKbdByName(ClientPtr client) irep.sequenceNumber= client->sequence; irep.length= 0; irep.which= XkbAllIndicatorsMask; - XkbComputeGetIndicatorMapReplySize(finfo.xkb->indicators,&irep); + XkbComputeGetIndicatorMapReplySize(new->indicators,&irep); rep.length+= SIZEOF(xGenericReply)/4+irep.length; } - if (finfo.xkb->names==NULL) + if (new->names==NULL) rep.reported&= ~(XkbGBN_OtherNamesMask|XkbGBN_KeyNamesMask); else if (rep.reported&(XkbGBN_OtherNamesMask|XkbGBN_KeyNamesMask)) { nrep.type= X_Reply; nrep.deviceID= dev->id; nrep.sequenceNumber= client->sequence; nrep.length= 0; - nrep.minKeyCode= finfo.xkb->min_key_code; - nrep.maxKeyCode= finfo.xkb->max_key_code; + nrep.minKeyCode= new->min_key_code; + nrep.maxKeyCode= new->max_key_code; if (rep.reported&XkbGBN_OtherNamesMask) { nrep.which= XkbAllNamesMask; - if (finfo.xkb->map!=NULL) - nrep.nTypes= finfo.xkb->map->num_types; + if (new->map!=NULL) + nrep.nTypes= new->map->num_types; else nrep.nTypes= 0; nrep.nKTLevels= 0; nrep.groupNames= XkbAllGroupsMask; nrep.virtualMods= XkbAllVirtualModsMask; nrep.indicators= XkbAllIndicatorsMask; - nrep.nRadioGroups= finfo.xkb->names->num_rg; + nrep.nRadioGroups= new->names->num_rg; } else { nrep.which= 0; @@ -5317,9 +5316,9 @@ ProcXkbGetKbdByName(ClientPtr client) } if (rep.reported&XkbGBN_KeyNamesMask) { nrep.which|= XkbKeyNamesMask; - nrep.firstKey= finfo.xkb->min_key_code; - nrep.nKeys= XkbNumKeys(finfo.xkb); - nrep.nKeyAliases= finfo.xkb->names->num_key_aliases; + nrep.firstKey= new->min_key_code; + nrep.nKeys= XkbNumKeys(new); + nrep.nKeyAliases= new->names->num_key_aliases; if (nrep.nKeyAliases) nrep.which|= XkbKeyAliasesMask; } @@ -5328,10 +5327,10 @@ ProcXkbGetKbdByName(ClientPtr client) nrep.firstKey= nrep.nKeys= 0; nrep.nKeyAliases= 0; } - XkbComputeGetNamesReplySize(finfo.xkb,&nrep); + XkbComputeGetNamesReplySize(new,&nrep); rep.length+= SIZEOF(xGenericReply)/4+nrep.length; } - if (finfo.xkb->geom==NULL) + if (new->geom==NULL) rep.reported&= ~XkbGBN_GeometryMask; else if (rep.reported&XkbGBN_GeometryMask) { grep.type= X_Reply; @@ -5344,7 +5343,7 @@ ProcXkbGetKbdByName(ClientPtr client) grep.nProperties= grep.nColors= grep.nShapes= 0; grep.nSections= grep.nDoodads= 0; grep.baseColorNdx= grep.labelColorNdx= 0; - XkbComputeGetGeometryReplySize(finfo.xkb->geom,&grep,None); + XkbComputeGetGeometryReplySize(new->geom,&grep,None); rep.length+= SIZEOF(xGenericReply)/4+grep.length; } } @@ -5359,23 +5358,23 @@ ProcXkbGetKbdByName(ClientPtr client) } WriteToClient(client,SIZEOF(xkbGetKbdByNameReply), (char *)&rep); if (reported&(XkbGBN_SymbolsMask|XkbGBN_TypesMask)) - XkbSendMap(client,finfo.xkb,&mrep); + XkbSendMap(client,new,&mrep); if (reported&XkbGBN_CompatMapMask) - XkbSendCompatMap(client,finfo.xkb->compat,&crep); + XkbSendCompatMap(client,new->compat,&crep); if (reported&XkbGBN_IndicatorMapMask) - XkbSendIndicatorMap(client,finfo.xkb->indicators,&irep); + XkbSendIndicatorMap(client,new->indicators,&irep); if (reported&(XkbGBN_KeyNamesMask|XkbGBN_OtherNamesMask)) - XkbSendNames(client,finfo.xkb,&nrep); + XkbSendNames(client,new,&nrep); if (reported&XkbGBN_GeometryMask) - XkbSendGeometry(client,finfo.xkb->geom,&grep,False); + XkbSendGeometry(client,new->geom,&grep,False); if (rep.loaded) { XkbDescPtr old_xkb; xkbNewKeyboardNotify nkn; int i,nG,nTG; old_xkb= xkb; - xkb= finfo.xkb; + xkb= new; dev->key->xkbInfo->desc= xkb; - finfo.xkb= old_xkb; /* so it'll get freed automatically */ + new= old_xkb; /* so it'll get freed automatically */ *xkb->ctrls= *old_xkb->ctrls; for (nG=nTG=0,i=xkb->min_key_code;i<=xkb->max_key_code;i++) { @@ -5419,8 +5418,8 @@ ProcXkbGetKbdByName(ClientPtr client) /* this should be either a MN or an NKN, depending on whether or not * the keycode range changed? */ nkn.deviceID= nkn.oldDeviceID= dev->id; - nkn.minKeyCode= finfo.xkb->min_key_code; - nkn.maxKeyCode= finfo.xkb->max_key_code; + nkn.minKeyCode= new->min_key_code; + nkn.maxKeyCode= new->max_key_code; nkn.oldMinKeyCode= xkb->min_key_code; nkn.oldMaxKeyCode= xkb->max_key_code; nkn.requestMajor= XkbReqCode; @@ -5430,9 +5429,9 @@ ProcXkbGetKbdByName(ClientPtr client) nkn.changed|= XkbNKN_GeometryMask; XkbSendNewKeyboardNotify(dev,&nkn); } - if ((finfo.xkb!=NULL)&&(finfo.xkb!=xkb)) { - XkbFreeKeyboard(finfo.xkb,XkbAllComponentsMask,True); - finfo.xkb= NULL; + if ((new!=NULL)&&(new!=xkb)) { + XkbFreeKeyboard(new,XkbAllComponentsMask,True); + new= NULL; } if (names.keymap) { _XkbFree(names.keymap); names.keymap= NULL; } if (names.keycodes) { _XkbFree(names.keycodes); names.keycodes= NULL; } diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c index 2aacc8ca6..890cf4250 100644 --- a/xkb/xkbActions.c +++ b/xkb/xkbActions.c @@ -843,7 +843,7 @@ _XkbFilterRedirectKey( XkbSrvInfoPtr xkbi, unsigned keycode, XkbAction * pAction) { -unsigned realMods; +unsigned realMods = 0; xEvent ev; int x,y; XkbStateRec old; @@ -1145,7 +1145,7 @@ void XkbHandleActions(DeviceIntPtr dev,DeviceIntPtr kbd,xEvent *xE,int count) { int key,bit,i; -CARD8 realMods; +CARD8 realMods = 0; XkbSrvInfoPtr xkbi; KeyClassPtr keyc; int changed,sendEvent; diff --git a/xkb/xkbInit.c b/xkb/xkbInit.c index 73dd32e35..37dd94019 100644 --- a/xkb/xkbInit.c +++ b/xkb/xkbInit.c @@ -88,7 +88,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. typedef struct _SrvXkmInfo { DeviceIntPtr dev; FILE * file; - XkbFileInfo xkbinfo; + XkbDescPtr xkb; } SrvXkmInfo; @@ -125,7 +125,6 @@ typedef struct _SrvXkmInfo { char * XkbBaseDirectory= XKB_BASE_DIRECTORY; char * XkbBinDirectory= XKB_BIN_DIRECTORY; static int XkbWantAccessX= 0; -static XkbFileInfo * _XkbInitFileInfo= NULL; static Bool rulesDefined= False; static char * XkbRulesFile= NULL; @@ -283,10 +282,8 @@ XkbSetRulesDflts(char *rulesFile,char *model,char *layout, #include "xkbDflts.h" static Bool -XkbInitKeyTypes(XkbDescPtr xkb,SrvXkmInfo *file) +XkbInitKeyTypes(XkbDescPtr xkb) { - if (file->xkbinfo.defined&XkmTypesMask) - return True; initTypeNames(NULL); if (XkbAllocClientMap(xkb,XkbKeyTypesMask,num_dflt_types)!=Success) return False; @@ -299,7 +296,7 @@ XkbInitKeyTypes(XkbDescPtr xkb,SrvXkmInfo *file) } static void -XkbInitRadioGroups(XkbSrvInfoPtr xkbi,SrvXkmInfo *file) +XkbInitRadioGroups(XkbSrvInfoPtr xkbi) { xkbi->nRadioGroups = 0; xkbi->radioGroups = NULL; @@ -308,13 +305,11 @@ XkbInitRadioGroups(XkbSrvInfoPtr xkbi,SrvXkmInfo *file) static Status -XkbInitCompatStructs(XkbDescPtr xkb,SrvXkmInfo *file) +XkbInitCompatStructs(XkbDescPtr xkb) { register int i; XkbCompatMapPtr compat; - if (file->xkbinfo.defined&XkmCompatMapMask) - return Success; if (XkbAllocCompatMap(xkb,XkbAllCompatMask,num_dfltSI)!=Success) return BadAlloc; compat = xkb->compat; @@ -335,17 +330,17 @@ XkbCompatMapPtr compat; } static void -XkbInitSemantics(XkbDescPtr xkb,SrvXkmInfo *file) +XkbInitSemantics(XkbDescPtr xkb) { - XkbInitKeyTypes(xkb,file); - XkbInitCompatStructs(xkb,file); + XkbInitKeyTypes(xkb); + XkbInitCompatStructs(xkb); return; } /***====================================================================***/ static Status -XkbInitNames(XkbSrvInfoPtr xkbi,SrvXkmInfo *file) +XkbInitNames(XkbSrvInfoPtr xkbi) { XkbDescPtr xkb; XkbNamesPtr names; @@ -363,29 +358,25 @@ Atom unknown; if (names->symbols==None) names->symbols= unknown; if (names->types==None) names->types= unknown; if (names->compat==None) names->compat= unknown; - if ((file->xkbinfo.defined&XkmVirtualModsMask)==0) { - if (names->vmods[vmod_NumLock]==None) - names->vmods[vmod_NumLock]= CREATE_ATOM("NumLock"); - if (names->vmods[vmod_Alt]==None) - names->vmods[vmod_Alt]= CREATE_ATOM("Alt"); - if (names->vmods[vmod_AltGr]==None) - names->vmods[vmod_AltGr]= CREATE_ATOM("ModeSwitch"); - } - - if (((file->xkbinfo.defined&XkmIndicatorsMask)==0)|| - ((file->xkbinfo.defined&XkmGeometryMask)==0)) { - initIndicatorNames(NULL,xkb); - if (names->indicators[LED_CAPS-1]==None) - names->indicators[LED_CAPS-1] = CREATE_ATOM("Caps Lock"); - if (names->indicators[LED_NUM-1]==None) - names->indicators[LED_NUM-1] = CREATE_ATOM("Num Lock"); - if (names->indicators[LED_SCROLL-1]==None) - names->indicators[LED_SCROLL-1] = CREATE_ATOM("Scroll Lock"); + if (names->vmods[vmod_NumLock]==None) + names->vmods[vmod_NumLock]= CREATE_ATOM("NumLock"); + if (names->vmods[vmod_Alt]==None) + names->vmods[vmod_Alt]= CREATE_ATOM("Alt"); + if (names->vmods[vmod_AltGr]==None) + names->vmods[vmod_AltGr]= CREATE_ATOM("ModeSwitch"); + + initIndicatorNames(NULL,xkb); + if (names->indicators[LED_CAPS-1]==None) + names->indicators[LED_CAPS-1] = CREATE_ATOM("Caps Lock"); + if (names->indicators[LED_NUM-1]==None) + names->indicators[LED_NUM-1] = CREATE_ATOM("Num Lock"); + if (names->indicators[LED_SCROLL-1]==None) + names->indicators[LED_SCROLL-1] = CREATE_ATOM("Scroll Lock"); #ifdef LED_COMPOSE - if (names->indicators[LED_COMPOSE-1]==None) - names->indicators[LED_COMPOSE-1] = CREATE_ATOM("Compose"); + if (names->indicators[LED_COMPOSE-1]==None) + names->indicators[LED_COMPOSE-1] = CREATE_ATOM("Compose"); #endif - } + if (xkb->geom!=NULL) names->geometry= xkb->geom->name; else names->geometry= unknown; @@ -393,7 +384,7 @@ Atom unknown; } static Status -XkbInitIndicatorMap(XkbSrvInfoPtr xkbi,SrvXkmInfo *file) +XkbInitIndicatorMap(XkbSrvInfoPtr xkbi) { XkbDescPtr xkb; XkbIndicatorPtr map; @@ -402,27 +393,24 @@ XkbSrvLedInfoPtr sli; xkb= xkbi->desc; if (XkbAllocIndicatorMaps(xkb)!=Success) return BadAlloc; - if ((file->xkbinfo.defined&XkmIndicatorsMask)==0) { - map= xkb->indicators; - map->phys_indicators = PHYS_LEDS; - map->maps[LED_CAPS-1].flags= XkbIM_NoExplicit; - map->maps[LED_CAPS-1].which_mods= XkbIM_UseLocked; - map->maps[LED_CAPS-1].mods.mask= LockMask; - map->maps[LED_CAPS-1].mods.real_mods= LockMask; - - map->maps[LED_NUM-1].flags= XkbIM_NoExplicit; - map->maps[LED_NUM-1].which_mods= XkbIM_UseLocked; - map->maps[LED_NUM-1].mods.mask= 0; - map->maps[LED_NUM-1].mods.real_mods= 0; - map->maps[LED_NUM-1].mods.vmods= vmod_NumLockMask; - -/* Metro Link */ - map->maps[LED_SCROLL-1].flags= XkbIM_NoExplicit; - map->maps[LED_SCROLL-1].which_mods= XkbIM_UseLocked; - map->maps[LED_SCROLL-1].mods.mask= Mod3Mask; - map->maps[LED_SCROLL-1].mods.real_mods= Mod3Mask; -/* Metro Link */ - } + map= xkb->indicators; + map->phys_indicators = PHYS_LEDS; + map->maps[LED_CAPS-1].flags= XkbIM_NoExplicit; + map->maps[LED_CAPS-1].which_mods= XkbIM_UseLocked; + map->maps[LED_CAPS-1].mods.mask= LockMask; + map->maps[LED_CAPS-1].mods.real_mods= LockMask; + + map->maps[LED_NUM-1].flags= XkbIM_NoExplicit; + map->maps[LED_NUM-1].which_mods= XkbIM_UseLocked; + map->maps[LED_NUM-1].mods.mask= 0; + map->maps[LED_NUM-1].mods.real_mods= 0; + map->maps[LED_NUM-1].mods.vmods= vmod_NumLockMask; + + map->maps[LED_SCROLL-1].flags= XkbIM_NoExplicit; + map->maps[LED_SCROLL-1].which_mods= XkbIM_UseLocked; + map->maps[LED_SCROLL-1].mods.mask= Mod3Mask; + map->maps[LED_SCROLL-1].mods.real_mods= Mod3Mask; + sli= XkbFindSrvLedInfo(xkbi->device,XkbDfltXIClass,XkbDfltXIId,0); if (sli) XkbCheckIndicatorMaps(xkbi->device,sli,XkbAllIndicatorsMask); @@ -430,7 +418,7 @@ XkbSrvLedInfoPtr sli; } static Status -XkbInitControls(DeviceIntPtr pXDev,XkbSrvInfoPtr xkbi,SrvXkmInfo *file) +XkbInitControls(DeviceIntPtr pXDev,XkbSrvInfoPtr xkbi) { XkbDescPtr xkb; XkbControlsPtr ctrls; @@ -440,8 +428,7 @@ XkbControlsPtr ctrls; if (XkbAllocControls(xkb,XkbAllControlsMask)!=Success) FatalError("Couldn't allocate keyboard controls\n"); ctrls= xkb->ctrls; - if ((file->xkbinfo.defined&XkmSymbolsMask)==0) - ctrls->num_groups = 1; + ctrls->num_groups = 1; ctrls->groups_wrap = XkbSetGroupInfo(1,XkbWrapIntoRange,0); ctrls->internal.mask = 0; ctrls->internal.real_mods = 0; @@ -464,29 +451,18 @@ XkbInitDevice(DeviceIntPtr pXDev) int i; XkbSrvInfoPtr xkbi; XkbChangesRec changes; -SrvXkmInfo file; unsigned check; XkbEventCauseRec cause; - file.dev= pXDev; - file.file=NULL; - bzero(&file.xkbinfo,sizeof(XkbFileInfo)); bzero(&changes,sizeof(XkbChangesRec)); pXDev->key->xkbInfo= xkbi= _XkbTypedCalloc(1,XkbSrvInfoRec); if ( xkbi ) { XkbDescPtr xkb; - if ((_XkbInitFileInfo!=NULL)&&(_XkbInitFileInfo->xkb!=NULL)) { - file.xkbinfo= *_XkbInitFileInfo; - xkbi->desc= _XkbInitFileInfo->xkb; - _XkbInitFileInfo= 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; - } + 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; xkb= xkbi->desc; if (xkb->min_key_code == 0) xkb->min_key_code = pXDev->key->curKeySyms.minKeyCode; @@ -509,32 +485,23 @@ XkbEventCauseRec cause; xkbi->dfltPtrDelta=1; xkbi->device = pXDev; - file.xkbinfo.xkb= xkb; - XkbInitSemantics(xkb,&file); - XkbInitNames(xkbi,&file); - XkbInitRadioGroups(xkbi,&file); + 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,&file); + XkbInitControls(pXDev,xkbi); - if (file.xkbinfo.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); + memcpy(xkb->map->modmap,pXDev->key->modifierMap,xkb->max_key_code+1); - XkbInitIndicatorMap(xkbi,&file); + XkbInitIndicatorMap(xkbi); XkbDDXInitDevice(pXDev); - if (!(file.xkbinfo.defined&XkmSymbolsMask)) { - XkbUpdateKeyTypesFromCore(pXDev,xkb->min_key_code,XkbNumKeys(xkb), - &changes); - } - else { - XkbUpdateCoreDescription(pXDev,True); - } + XkbUpdateKeyTypesFromCore(pXDev,xkb->min_key_code,XkbNumKeys(xkb), + &changes); XkbSetCauseUnknown(&cause); XkbUpdateActions(pXDev,xkb->min_key_code, XkbNumKeys(xkb),&changes, &check,&cause); @@ -546,8 +513,6 @@ XkbEventCauseRec cause; pXDev->key->curKeySyms.minKeyCode = xkb->min_key_code; pXDev->key->curKeySyms.maxKeyCode = xkb->max_key_code; } - if (file.file!=NULL) - fclose(file.file); return; } @@ -571,12 +536,12 @@ XkbInitKeyboardDeviceStruct( DeviceIntPtr /*device*/, KeybdCtrl * /*ctrl*/)) { -XkbFileInfo finfo; 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; @@ -633,13 +598,11 @@ XkbRF_VarDefsRec defs; } ok = (Bool) XkbDDXLoadKeymapByNames(dev,names,XkmAllIndicesMask,0, - &finfo,name,PATH_MAX); + &xkb,name,PATH_MAX); - if (ok && (finfo.xkb!=NULL)) { - XkbDescPtr xkb; + if (ok && (xkb!=NULL)) { KeyCode minKC,maxKC; - xkb= finfo.xkb; minKC= xkb->min_key_code; maxKC= xkb->max_key_code; if (XkbIsLegalKeycode(minKC)&&XkbIsLegalKeycode(maxKC)&&(minKC<=maxKC)&& @@ -669,13 +632,11 @@ XkbRF_VarDefsRec defs; pMods= tmpMods; } } - _XkbInitFileInfo= &finfo; } else { LogMessage(X_WARNING, "Couldn't load XKB keymap, falling back to pre-XKB keymap\n"); } ok= InitKeyboardDeviceStruct((DevicePtr)dev,pSyms,pMods,bellProc,ctrlProc); - _XkbInitFileInfo= NULL; if ((pSyms==&tmpSyms)&&(pSyms->map!=NULL)) { _XkbFree(pSyms->map); pSyms->map= NULL; diff --git a/xkb/xkbfmisc.c b/xkb/xkbfmisc.c index 4182c3a34..866b4b154 100644 --- a/xkb/xkbfmisc.c +++ b/xkb/xkbfmisc.c @@ -146,7 +146,7 @@ XkbWriteSectionFromName(FILE *file,char *sectionName,char *name) /* ARGSUSED */ static void _AddIncl( FILE * file, - XkbFileInfo * result, + XkbDescPtr xkb, Bool topLevel, Bool showImplicit, int index, @@ -169,9 +169,6 @@ unsigned complete; XkbNamesPtr old_names; int multi_section; unsigned wantNames,wantConfig,wantDflts; -XkbFileInfo finfo; - - bzero(&finfo,sizeof(XkbFileInfo)); complete= 0; if ((name=names->keymap)==NULL) name= "default"; @@ -187,14 +184,8 @@ XkbFileInfo finfo; if (want==0) return False; - if (xkb!=NULL) { + if (xkb!=NULL) old_names= xkb->names; - finfo.type= 0; - finfo.defined= 0; - finfo.xkb= xkb; - if (!XkbDetermineFileType(&finfo,XkbXKBFile,NULL)) - return False; - } else old_names= NULL; wantConfig= want&(~complete); @@ -304,7 +295,7 @@ XkbFileInfo finfo; wantNames= complete&(~(wantConfig|wantDflts)); name= names->keycodes; if (wantConfig&XkmKeyNamesMask) - XkbWriteXKBKeycodes(file,&finfo,False,False,_AddIncl,name); + XkbWriteXKBKeycodes(file,xkb,False,False,_AddIncl,name); else if (wantDflts&XkmKeyNamesMask) fprintf(stderr,"Default symbols not implemented yet!\n"); else if (wantNames&XkmKeyNamesMask) @@ -312,7 +303,7 @@ XkbFileInfo finfo; name= names->types; if (wantConfig&XkmTypesMask) - XkbWriteXKBKeyTypes(file,&finfo,False,False,_AddIncl,name); + XkbWriteXKBKeyTypes(file,xkb,False,False,_AddIncl,name); else if (wantDflts&XkmTypesMask) fprintf(stderr,"Default types not implemented yet!\n"); else if (wantNames&XkmTypesMask) @@ -320,7 +311,7 @@ XkbFileInfo finfo; name= names->compat; if (wantConfig&XkmCompatMapMask) - XkbWriteXKBCompatMap(file,&finfo,False,False,_AddIncl,name); + XkbWriteXKBCompatMap(file,xkb,False,False,_AddIncl,name); else if (wantDflts&XkmCompatMapMask) fprintf(stderr,"Default interps not implemented yet!\n"); else if (wantNames&XkmCompatMapMask) @@ -328,13 +319,13 @@ XkbFileInfo finfo; name= names->symbols; if (wantConfig&XkmSymbolsMask) - XkbWriteXKBSymbols(file,&finfo,False,False,_AddIncl,name); + XkbWriteXKBSymbols(file,xkb,False,False,_AddIncl,name); else if (wantNames&XkmSymbolsMask) XkbWriteSectionFromName(file,"symbols",name); name= names->geometry; if (wantConfig&XkmGeometryMask) - XkbWriteXKBGeometry(file,&finfo,False,False,_AddIncl,name); + XkbWriteXKBGeometry(file,xkb,False,False,_AddIncl,name); else if (wantNames&XkmGeometryMask) XkbWriteSectionFromName(file,"geometry",name); @@ -404,81 +395,6 @@ unsigned rtrn; return rtrn; } -Bool -XkbDetermineFileType(XkbFileInfoPtr finfo,int format,int *opts_missing) -{ -unsigned present; -XkbDescPtr xkb; - - if ((!finfo)||(!finfo->xkb)) - return False; - if (opts_missing) - *opts_missing= 0; - xkb= finfo->xkb; - present= 0; - if ((xkb->names)&&(xkb->names->keys)) present|= XkmKeyNamesMask; - if ((xkb->map)&&(xkb->map->types)) present|= XkmTypesMask; - if (xkb->compat) present|= XkmCompatMapMask; - if ((xkb->map)&&(xkb->map->num_syms>1)) present|= XkmSymbolsMask; - if (xkb->indicators) present|= XkmIndicatorsMask; - if (xkb->geom) present|= XkmGeometryMask; - if (!present) - return False; - else switch (present) { - case XkmKeyNamesMask: - finfo->type= XkmKeyNamesIndex; - finfo->defined= present; - return True; - case XkmTypesMask: - finfo->type= XkmTypesIndex; - finfo->defined= present; - return True; - case XkmCompatMapMask: - finfo->type= XkmCompatMapIndex; - finfo->defined= present; - return True; - case XkmSymbolsMask: - if (format!=XkbXKMFile) { - finfo->type= XkmSymbolsIndex; - finfo->defined= present; - return True; - } - break; - case XkmGeometryMask: - finfo->type= XkmGeometryIndex; - finfo->defined= present; - return True; - } - if ((present&(~XkmSemanticsLegal))==0) { - if ((XkmSemanticsRequired&present)==XkmSemanticsRequired) { - if (opts_missing) - *opts_missing= XkmSemanticsOptional&(~present); - finfo->type= XkmSemanticsFile; - finfo->defined= present; - return True; - } - } - else if ((present&(~XkmLayoutLegal))==0) { - if ((XkmLayoutRequired&present)==XkmLayoutRequired) { - if (opts_missing) - *opts_missing= XkmLayoutOptional&(~present); - finfo->type= XkmLayoutFile; - finfo->defined= present; - return True; - } - } - else if ((present&(~XkmKeymapLegal))==0) { - if ((XkmKeymapRequired&present)==XkmKeymapRequired) { - if (opts_missing) - *opts_missing= XkmKeymapOptional&(~present); - finfo->type= XkmKeymapFile; - finfo->defined= present; - return True; - } - } - return False; -} - /* all latin-1 alphanumerics, plus parens, slash, minus, underscore and */ /* wildcards */ diff --git a/xkb/xkbout.c b/xkb/xkbout.c index b72c05c60..229cc9258 100644 --- a/xkb/xkbout.c +++ b/xkb/xkbout.c @@ -90,9 +90,9 @@ Atom * vmodNames; /***====================================================================***/ static Bool -WriteXKBAction(FILE *file,XkbFileInfo *result,XkbAnyAction *action) +WriteXKBAction(FILE *file,XkbDescPtr xkb,XkbAnyAction *action) { - fprintf(file,"%s",XkbActionText(result->xkb,(XkbAction *)action,XkbXKBFile)); + fprintf(file,"%s",XkbActionText(xkb,(XkbAction *)action,XkbXKBFile)); return True; } @@ -100,7 +100,7 @@ WriteXKBAction(FILE *file,XkbFileInfo *result,XkbAnyAction *action) Bool XkbWriteXKBKeycodes( FILE * file, - XkbFileInfo * result, + XkbDescPtr xkb, Bool topLevel, Bool showImplicit, XkbFileAddOnFunc addOn, @@ -108,10 +108,8 @@ XkbWriteXKBKeycodes( FILE * file, { Atom kcName; register unsigned i; -XkbDescPtr xkb; char * alternate; - xkb= result->xkb; if ((!xkb)||(!xkb->names)||(!xkb->names->keys)) { _XkbLibError(_XkbErrMissingNames,"XkbWriteXKBKeycodes",0); return False; @@ -155,14 +153,14 @@ char * alternate; } } if (addOn) - (*addOn)(file,result,topLevel,showImplicit,XkmKeyNamesIndex,priv); + (*addOn)(file,xkb,topLevel,showImplicit,XkmKeyNamesIndex,priv); fprintf(file,"};\n\n"); return True; } Bool XkbWriteXKBKeyTypes( FILE * file, - XkbFileInfo * result, + XkbDescPtr xkb, Bool topLevel, Bool showImplicit, XkbFileAddOnFunc addOn, @@ -171,9 +169,7 @@ XkbWriteXKBKeyTypes( FILE * file, register unsigned i,n; XkbKeyTypePtr type; XkbKTMapEntryPtr entry; -XkbDescPtr xkb; - xkb= result->xkb; if ((!xkb)||(!xkb->map)||(!xkb->map->types)) { _XkbLibError(_XkbErrMissingTypes,"XkbWriteXKBKeyTypes",0); return False; @@ -223,22 +219,20 @@ XkbDescPtr xkb; fprintf(file," };\n"); } if (addOn) - (*addOn)(file,result,topLevel,showImplicit,XkmTypesIndex,priv); + (*addOn)(file,xkb,topLevel,showImplicit,XkmTypesIndex,priv); fprintf(file,"};\n\n"); return True; } static Bool WriteXKBIndicatorMap( FILE * file, - XkbFileInfo * result, + XkbDescPtr xkb, Atom name, XkbIndicatorMapPtr led, XkbFileAddOnFunc addOn, void * priv) { -XkbDescPtr xkb; - xkb= result->xkb; fprintf(file," indicator \"%s\" {\n",XkbAtomGetString(name)); if (led->flags&XkbIM_NoExplicit) fprintf(file," !allowExplicit;\n"); @@ -266,14 +260,14 @@ XkbDescPtr xkb; XkbControlsMaskText(led->ctrls,XkbXKBFile)); } if (addOn) - (*addOn)(file,result,False,True,XkmIndicatorsIndex,priv); + (*addOn)(file,xkb,False,True,XkmIndicatorsIndex,priv); fprintf(file," };\n"); return True; } Bool XkbWriteXKBCompatMap( FILE * file, - XkbFileInfo * result, + XkbDescPtr xkb, Bool topLevel, Bool showImplicit, XkbFileAddOnFunc addOn, @@ -281,9 +275,7 @@ XkbWriteXKBCompatMap( FILE * file, { register unsigned i; XkbSymInterpretPtr interp; -XkbDescPtr xkb; - xkb= result->xkb; if ((!xkb)||(!xkb->compat)||(!xkb->compat->sym_interpret)) { _XkbLibError(_XkbErrMissingCompatMap,"XkbWriteXKBCompatMap",0); return False; @@ -316,7 +308,7 @@ XkbDescPtr xkb; if (interp->flags&XkbSI_AutoRepeat) fprintf(file," repeat= True;\n"); fprintf(file," action= "); - WriteXKBAction(file,result,&interp->act); + WriteXKBAction(file,xkb,&interp->act); fprintf(file,";\n"); fprintf(file," };\n"); } @@ -337,32 +329,30 @@ XkbDescPtr xkb; (map->which_mods!=0)|| (map->mods.real_mods!=0)||(map->mods.vmods!=0)|| (map->ctrls!=0)) { - WriteXKBIndicatorMap(file,result,xkb->names->indicators[i],map, + WriteXKBIndicatorMap(file,xkb,xkb->names->indicators[i],map, addOn,priv); } } } if (addOn) - (*addOn)(file,result,topLevel,showImplicit,XkmCompatMapIndex,priv); + (*addOn)(file,xkb,topLevel,showImplicit,XkmCompatMapIndex,priv); fprintf(file,"};\n\n"); return True; } Bool XkbWriteXKBSymbols( FILE * file, - XkbFileInfo * result, + XkbDescPtr xkb, Bool topLevel, Bool showImplicit, XkbFileAddOnFunc addOn, void * priv) { register unsigned i,tmp; -XkbDescPtr xkb; XkbClientMapPtr map; XkbServerMapPtr srv; Bool showActions; - xkb= result->xkb; map= xkb->map; srv= xkb->server; if ((!xkb)||(!map)||(!map->syms)||(!map->key_sym_map)) { @@ -517,7 +507,7 @@ Bool showActions; for (s=0;sxkb; if ((!xkb)||(!xkb->geom)) { _XkbLibError(_XkbErrMissingGeometry,"XkbWriteXKBGeometry",0); return False; @@ -901,7 +889,7 @@ XkbGeometryPtr geom; } } if (addOn) - (*addOn)(file,result,topLevel,showImplicit,XkmGeometryIndex,priv); + (*addOn)(file,xkb,topLevel,showImplicit,XkmGeometryIndex,priv); fprintf(file,"};\n\n"); return True; } diff --git a/xkb/xkmread.c b/xkb/xkmread.c index 1e5b2cb4e..b14a5beda 100644 --- a/xkb/xkmread.c +++ b/xkb/xkmread.c @@ -165,14 +165,12 @@ int count,nRead=0; /***====================================================================***/ static int -ReadXkmVirtualMods(FILE *file,XkbFileInfo *result,XkbChangesPtr changes) +ReadXkmVirtualMods(FILE *file,XkbDescPtr xkb,XkbChangesPtr changes) { register unsigned int i,bit; unsigned int bound,named,tmp; int nRead=0; -XkbDescPtr xkb; - xkb= result->xkb; if (XkbAllocServerMap(xkb,XkbVirtualModsMask,0)!=Success) { _XkbLibError(_XkbErrBadAlloc,"ReadXkmVirtualMods",0); return -1; @@ -209,16 +207,14 @@ XkbDescPtr xkb; /***====================================================================***/ static int -ReadXkmKeycodes(FILE *file,XkbFileInfo *result,XkbChangesPtr changes) +ReadXkmKeycodes(FILE *file,XkbDescPtr xkb,XkbChangesPtr changes) { register int i; unsigned minKC,maxKC,nAl; int nRead=0; char name[100]; XkbKeyNamePtr pN; -XkbDescPtr xkb; - xkb= result->xkb; name[0]= '\0'; nRead+= XkmGetCountedString(file,name,100); minKC= XkmGetCARD8(file,&nRead); @@ -276,7 +272,7 @@ XkbDescPtr xkb; /***====================================================================***/ static int -ReadXkmKeyTypes(FILE *file,XkbFileInfo *result,XkbChangesPtr changes) +ReadXkmKeyTypes(FILE *file,XkbDescPtr xkb,XkbChangesPtr changes) { register unsigned i,n; unsigned num_types; @@ -287,9 +283,7 @@ xkmKeyTypeDesc wire; XkbKTMapEntryPtr entry; xkmKTMapEntryDesc wire_entry; char buf[100]; -XkbDescPtr xkb; - xkb= result->xkb; if ((tmp= XkmGetCountedString(file,buf,100))<1) { _XkbLibError(_XkbErrBadLength,"ReadXkmKeyTypes",0); return -1; @@ -414,7 +408,7 @@ XkbDescPtr xkb; /***====================================================================***/ static int -ReadXkmCompatMap(FILE *file,XkbFileInfo *result,XkbChangesPtr changes) +ReadXkmCompatMap(FILE *file,XkbDescPtr xkb,XkbChangesPtr changes) { register int i; unsigned num_si,groups; @@ -423,10 +417,8 @@ XkbSymInterpretPtr interp; xkmSymInterpretDesc wire; unsigned tmp; int nRead=0; -XkbDescPtr xkb; XkbCompatMapPtr compat; - xkb= result->xkb; if ((tmp= XkmGetCountedString(file,name,100))<1) { _XkbLibError(_XkbErrBadLength,"ReadXkmCompatMap",0); return -1; @@ -492,16 +484,14 @@ XkbCompatMapPtr compat; } static int -ReadXkmIndicators(FILE *file,XkbFileInfo *result,XkbChangesPtr changes) +ReadXkmIndicators(FILE *file,XkbDescPtr xkb,XkbChangesPtr changes) { register unsigned nLEDs; xkmIndicatorMapDesc wire; char buf[100]; unsigned tmp; int nRead=0; -XkbDescPtr xkb; - xkb= result->xkb; if ((xkb->indicators==NULL)&&(XkbAllocIndicatorMaps(xkb)!=Success)) { _XkbLibError(_XkbErrBadAlloc,"indicator rec",0); return -1; @@ -575,16 +565,14 @@ FindTypeForKey(XkbDescPtr xkb,Atom name,unsigned width,KeySym *syms) } static int -ReadXkmSymbols(FILE *file,XkbFileInfo *result) +ReadXkmSymbols(FILE *file,XkbDescPtr xkb) { register int i,g,s,totalVModMaps; xkmKeySymMapDesc wireMap; char buf[100]; unsigned minKC,maxKC,groupNames,tmp; int nRead=0; -XkbDescPtr xkb; - xkb= result->xkb; if ((tmp=XkmGetCountedString(file,buf,100))<1) return -1; nRead+= tmp; @@ -911,7 +899,7 @@ Atom nameAtom; } static int -ReadXkmGeometry(FILE *file,XkbFileInfo *result) +ReadXkmGeometry(FILE *file,XkbDescPtr xkb) { register int i; char buf[100]; @@ -931,11 +919,11 @@ XkbGeometrySizesRec sizes; sizes.num_sections= wireGeom.num_sections; sizes.num_doodads= wireGeom.num_doodads; sizes.num_key_aliases= wireGeom.num_key_aliases; - if (XkbAllocGeometry(result->xkb,&sizes)!=Success) { + if (XkbAllocGeometry(xkb,&sizes)!=Success) { _XkbLibError(_XkbErrBadAlloc,"ReadXkmGeometry",0); return nRead; } - geom= result->xkb->geom; + geom= xkb->geom; geom->name= XkbInternAtom(buf,False); geom->width_mm= wireGeom.width_mm; geom->height_mm= wireGeom.height_mm; @@ -1055,7 +1043,7 @@ int nRead=0; return 1; } -Bool +static Bool XkmReadTOC(FILE *file,xkmFileInfo* file_info,int max_toc,xkmSectionInfo *toc) { unsigned hdr,tmp; @@ -1086,117 +1074,11 @@ unsigned i,size_toc; return 1; } -Bool -XkmReadFileSection( FILE * file, - xkmSectionInfo * toc, - XkbFileInfo * result, - unsigned * loaded_rtrn) -{ -xkmSectionInfo tmpTOC; -int nRead; - - if ((!result)||(!result->xkb)) { - _XkbLibError(_XkbErrBadMatch,"XkmReadFileSection",0); - return 0; - } - fseek(file,toc->offset,SEEK_SET); - fread(&tmpTOC,SIZEOF(xkmSectionInfo),1,file); - nRead= SIZEOF(xkmSectionInfo); - if ((tmpTOC.type!=toc->type)||(tmpTOC.format!=toc->format)|| - (tmpTOC.size!=toc->size)||(tmpTOC.offset!=toc->offset)) { - _XkbLibError(_XkbErrIllegalContents,"XkmReadFileSection",0); - return 0; - } - switch (tmpTOC.type) { - case XkmVirtualModsIndex: - nRead+= ReadXkmVirtualMods(file,result,NULL); - if ((loaded_rtrn)&&(nRead>=0)) - *loaded_rtrn|= XkmVirtualModsMask; - break; - case XkmTypesIndex: - nRead+= ReadXkmKeyTypes(file,result,NULL); - if ((loaded_rtrn)&&(nRead>=0)) - *loaded_rtrn|= XkmTypesMask; - break; - case XkmCompatMapIndex: - nRead+= ReadXkmCompatMap(file,result,NULL); - if ((loaded_rtrn)&&(nRead>=0)) - *loaded_rtrn|= XkmCompatMapMask; - break; - case XkmKeyNamesIndex: - nRead+= ReadXkmKeycodes(file,result,NULL); - if ((loaded_rtrn)&&(nRead>=0)) - *loaded_rtrn|= XkmKeyNamesMask; - break; - case XkmSymbolsIndex: - nRead+= ReadXkmSymbols(file,result); - if ((loaded_rtrn)&&(nRead>=0)) - *loaded_rtrn|= XkmSymbolsMask; - break; - case XkmIndicatorsIndex: - nRead+= ReadXkmIndicators(file,result,NULL); - if ((loaded_rtrn)&&(nRead>=0)) - *loaded_rtrn|= XkmIndicatorsMask; - break; - case XkmGeometryIndex: - nRead+= ReadXkmGeometry(file,result); - if ((loaded_rtrn)&&(nRead>=0)) - *loaded_rtrn|= XkmGeometryMask; - break; - default: - _XkbLibError(_XkbErrBadImplementation, - XkbConfigText(tmpTOC.type,XkbMessage),0); - nRead= 0; - break; - } - if (nRead!=tmpTOC.size) { - _XkbLibError(_XkbErrBadLength,XkbConfigText(tmpTOC.type,XkbMessage), - nRead-tmpTOC.size); - return 0; - } - return (nRead>=0); -} - -char * -XkmReadFileSectionName(FILE *file,xkmSectionInfo *toc) -{ -xkmSectionInfo tmpTOC; -char name[100]; - - if ((!file)||(!toc)) - return 0; - switch (toc->type) { - case XkmVirtualModsIndex: - case XkmIndicatorsIndex: - break; - case XkmTypesIndex: - case XkmCompatMapIndex: - case XkmKeyNamesIndex: - case XkmSymbolsIndex: - case XkmGeometryIndex: - fseek(file,toc->offset,SEEK_SET); - fread(&tmpTOC,SIZEOF(xkmSectionInfo),1,file); - if ((tmpTOC.type!=toc->type)||(tmpTOC.format!=toc->format)|| - (tmpTOC.size!=toc->size)||(tmpTOC.offset!=toc->offset)) { - _XkbLibError(_XkbErrIllegalContents,"XkmReadFileSectionName",0); - return 0; - } - if (XkmGetCountedString(file,name,100)>0) - return _XkbDupString(name); - break; - default: - _XkbLibError(_XkbErrBadImplementation, - XkbConfigText(tmpTOC.type,XkbMessage),0); - break; - } - return NULL; -} - /***====================================================================***/ #define MAX_TOC 16 unsigned -XkmReadFile(FILE *file,unsigned need,unsigned want,XkbFileInfo *result) +XkmReadFile(FILE *file,unsigned need,unsigned want,XkbDescPtr *xkb) { register unsigned i; xkmSectionInfo toc[MAX_TOC],tmpTOC; @@ -1211,9 +1093,8 @@ unsigned which= need|want; need&(~fileInfo.present)); return which; } - result->type= fileInfo.type; - if (result->xkb==NULL) - result->xkb= XkbAllocKeyboard(); + if (*xkb==NULL) + *xkb= XkbAllocKeyboard(); for (i=0;i0) { nRead+= tmp; which&= ~(1<defined|= (1<defined|= (1<