summaryrefslogtreecommitdiff
path: root/xkb/xkbInit.c
diff options
context:
space:
mode:
authorDaniel Stone <daniel@fooishbar.org>2008-02-16 20:01:18 +0200
committerDaniel Stone <daniel@fooishbar.org>2008-02-17 22:52:08 +0200
commitfbd776894658e7afb2c55dc8582b2a3efab78a3c (patch)
tree0879ce2f27f34ff86aea76647ea1556724658da7 /xkb/xkbInit.c
parente5f002eddef1abe324033a3155f01d048536a48d (diff)
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.
Diffstat (limited to 'xkb/xkbInit.c')
-rw-r--r--xkb/xkbInit.c163
1 files changed, 62 insertions, 101 deletions
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;