Commit fbd77689 authored by Daniel Stone's avatar Daniel Stone

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.
parent e5f002ed
......@@ -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 */
);
......
......@@ -1005,7 +1005,7 @@ extern unsigned int XkbDDXLoadKeymapByNames(
XkbComponentNamesPtr /* names */,
unsigned int /* want */,
unsigned int /* need */,
XkbFileInfoPtr /* finfoRtrn */,
XkbDescPtr * /* finfoRtrn */,
char * /* keymapNameRtrn */,
int /* keymapNameRtrnLen */
);
......
......@@ -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;
......
......@@ -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);
......
......@@ -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; }
......
......@@ -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;
......
This diff is collapsed.
......@@ -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 */
......
......@@ -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;