diff options
Diffstat (limited to 'xkb/xkbUtils.c')
-rw-r--r-- | xkb/xkbUtils.c | 201 |
1 files changed, 22 insertions, 179 deletions
diff --git a/xkb/xkbUtils.c b/xkb/xkbUtils.c index 7d81d0169..f3ba6bc17 100644 --- a/xkb/xkbUtils.c +++ b/xkb/xkbUtils.c @@ -24,7 +24,7 @@ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ********************************************************/ -/* $XFree86: xc/programs/Xserver/xkb/xkbUtils.c,v 3.13 2001/08/23 14:33:26 alanh Exp $ */ +/* $XFree86: xc/programs/Xserver/xkb/xkbUtils.c,v 3.17 2003/11/17 22:20:46 dawes Exp $ */ #include <stdio.h> #include <ctype.h> @@ -40,12 +40,13 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #define XKBSRV_NEED_FILE_FUNCS #include "XKBsrv.h" #include "extensions/XKBgeom.h" +#include "xkb.h" #ifdef MODE_SWITCH extern Bool noKME; /* defined in os/utils.c */ #endif - int XkbDisableLockActions = 0; +int XkbDisableLockActions = 0; /***====================================================================***/ @@ -60,13 +61,7 @@ extern Bool noKME; /* defined in os/utils.c */ /***====================================================================***/ DeviceIntPtr -#if NeedFunctionPrototypes _XkbLookupAnyDevice(int id,int *why_rtrn) -#else -_XkbLookupAnyDevice(id,why_rtrn) - int id; - int *why_rtrn; -#endif { DeviceIntPtr dev = NULL; @@ -90,13 +85,7 @@ DeviceIntPtr dev = NULL; } DeviceIntPtr -#if NeedFunctionPrototypes _XkbLookupKeyboard(int id,int *why_rtrn) -#else -_XkbLookupKeyboard(id,why_rtrn) - int id; - int *why_rtrn; -#endif { DeviceIntPtr dev = NULL; @@ -111,13 +100,7 @@ DeviceIntPtr dev = NULL; } DeviceIntPtr -#if NeedFunctionPrototypes _XkbLookupBellDevice(int id,int *why_rtrn) -#else -_XkbLookupBellDevice(id,why_rtrn) - int id; - int *why_rtrn; -#endif { DeviceIntPtr dev = NULL; @@ -132,13 +115,7 @@ DeviceIntPtr dev = NULL; } DeviceIntPtr -#if NeedFunctionPrototypes _XkbLookupLedDevice(int id,int *why_rtrn) -#else -_XkbLookupLedDevice(id,why_rtrn) - int id; - int *why_rtrn; -#endif { DeviceIntPtr dev = NULL; @@ -153,13 +130,7 @@ DeviceIntPtr dev = NULL; } DeviceIntPtr -#if NeedFunctionPrototypes _XkbLookupButtonDevice(int id,int *why_rtrn) -#else -_XkbLookupButtonDevice(id,why_rtrn) - int id; - int *why_rtrn; -#endif { DeviceIntPtr dev = NULL; @@ -174,14 +145,7 @@ DeviceIntPtr dev = NULL; } void -#if NeedFunctionPrototypes XkbSetActionKeyMods(XkbDescPtr xkb,XkbAction *act,unsigned mods) -#else -XkbSetActionKeyMods(xkb,act,mods) - XkbDescPtr xkb; - XkbAction * act; - unsigned mods; -#endif { register unsigned tmp; @@ -203,13 +167,7 @@ register unsigned tmp; } unsigned -#if NeedFunctionPrototypes XkbMaskForVMask(XkbDescPtr xkb,unsigned vmask) -#else -XkbMaskForVMask(xkb,vmask) - XkbDescPtr xkb; - unsigned vmask; -#endif { register int i,bit; register unsigned mask; @@ -223,20 +181,11 @@ register unsigned mask; Bool -#if NeedFunctionPrototypes XkbApplyVModChanges( XkbSrvInfoPtr xkbi, unsigned changed, XkbChangesPtr changes, unsigned * needChecksRtrn, XkbEventCausePtr cause) -#else -XkbApplyVModChanges(xkbi,changed,changes,needChecksRtrn,cause) - XkbSrvInfoPtr xkbi; - unsigned changed; - XkbChangesPtr changes; - unsigned * needChecksRtrn; - XkbEventCausePtr cause; -#endif { XkbDescPtr xkb; Bool check; @@ -270,20 +219,11 @@ register unsigned i,bit; /***====================================================================***/ -#if NeedFunctionPrototypes void XkbUpdateKeyTypesFromCore( DeviceIntPtr pXDev, KeyCode first, CARD8 num, XkbChangesPtr changes) -#else -void -XkbUpdateKeyTypesFromCore(pXDev,first,num,changes) - DeviceIntPtr pXDev; - KeyCode first; - CARD8 num; - XkbChangesPtr changes; -#endif { XkbDescPtr xkb; unsigned key,nG,explicit; @@ -344,18 +284,10 @@ generate a NewKeyboard notify here? } void -#if NeedFunctionPrototypes XkbUpdateDescActions( XkbDescPtr xkb, KeyCode first, CARD8 num, XkbChangesPtr changes) -#else -XkbUpdateDescActions(xkb,first,num,changes) - XkbDescPtr xkb; - KeyCode first; - CARD8 num; - XkbChangesPtr changes; -#endif { register unsigned key; @@ -410,7 +342,6 @@ register unsigned key; return; } -#if NeedFunctionPrototypes void XkbUpdateActions( DeviceIntPtr pXDev, KeyCode first, @@ -418,16 +349,6 @@ XkbUpdateActions( DeviceIntPtr pXDev, XkbChangesPtr changes, unsigned * needChecksRtrn, XkbEventCausePtr cause) -#else -void -XkbUpdateActions(pXDev,first,num,changes,needChecksRtrn,cause) - DeviceIntPtr pXDev; - KeyCode first; - CARD8 num; - XkbChangesPtr changes; - unsigned * needChecksRtrn; - XkbEventCausePtr cause; -#endif { XkbSrvInfoPtr xkbi; XkbDescPtr xkb; @@ -453,13 +374,7 @@ CARD8 * repeat; } void -#if NeedFunctionPrototypes XkbUpdateCoreDescription(DeviceIntPtr keybd,Bool resize) -#else -XkbUpdateCoreDescription(keybd,resize) - DeviceIntPtr keybd; - Bool resize; -#endif { register int key,tmp; int maxSymsPerKey,maxKeysPerMod; @@ -517,14 +432,19 @@ CARD8 keysPerMod[XkbNumModifiers]; nGroups= XkbKeyNumGroups(xkb,key); tmp= 0; if (nGroups>0) { - if ((w=XkbKeyGroupWidth(xkb,key,XkbGroup1Index))<2) + if ((w=XkbKeyGroupWidth(xkb,key,XkbGroup1Index))<=2) tmp+= 2; - else tmp+= w; + else tmp+= w + 2; } if (nGroups>1) { - if ((w=XkbKeyGroupWidth(xkb,key,XkbGroup2Index))<2) - tmp+= 2; - else tmp+= w; + if (tmp <= 2) { + if ((w=XkbKeyGroupWidth(xkb,key,XkbGroup2Index))<2) + tmp+= 2; + else tmp+= w; + } else { + if ((w=XkbKeyGroupWidth(xkb,key,XkbGroup2Index))>2) + tmp+= w - 2; + } } if (nGroups>2) tmp+= XkbKeyGroupWidth(xkb,key,XkbGroup3Index); @@ -613,12 +533,17 @@ CARD8 keysPerMod[XkbNumModifiers]; pXKB+= XkbKeyGroupsWidth(xkb,key); for (n=XkbGroup3Index;n<nGroups;n++) { register int s; - groupWidth= XkbKeyGroupWidth(xkb,key,XkbGroup2Index); + groupWidth= XkbKeyGroupWidth(xkb,key,n); for (s=0;s<groupWidth;s++) { pCore[nOut++]= pXKB[s]; } pXKB+= XkbKeyGroupsWidth(xkb,key); } + if (!pCore[2] && !pCore[3] && maxSymsPerKey >= 6 && + (pCore[4] || pCore[5])) { + pCore[2] = pCore[4]; + pCore[3] = pCore[5]; + } } if (keyc->modifierMap[key]!=0) { register unsigned bit,i,mask; @@ -642,14 +567,7 @@ CARD8 keysPerMod[XkbNumModifiers]; } void -#if NeedFunctionPrototypes XkbSetRepeatKeys(DeviceIntPtr pXDev,int key,int onoff) -#else -XkbSetRepeatKeys(pXDev,key,onoff) - DeviceIntPtr pXDev; - int key; - int onoff; -#endif { if (pXDev && pXDev->key && pXDev->key->xkbInfo) { xkbControlsNotify cn; @@ -672,22 +590,12 @@ XkbSetRepeatKeys(pXDev,key,onoff) return; } -#if NeedFunctionPrototypes void XkbApplyMappingChange( DeviceIntPtr kbd, CARD8 request, KeyCode firstKey, CARD8 num, ClientPtr client) -#else -void -XkbApplyMappingChange(kbd,request,firstKey,num,client) - DeviceIntPtr kbd; - CARD8 request; - KeyCode firstKey; - CARD8 num; - ClientPtr client; -#endif { XkbEventCauseRec cause; XkbChangesRec changes; @@ -725,13 +633,7 @@ unsigned check; } void -#if NeedFunctionPrototypes XkbDisableComputedAutoRepeats(DeviceIntPtr dev,unsigned key) -#else -XkbDisableComputedAutoRepeats(dev,key) - DeviceIntPtr dev; - unsigned key; -#endif { XkbSrvInfoPtr xkbi = dev->key->xkbInfo; xkbMapNotify mn; @@ -746,13 +648,7 @@ xkbMapNotify mn; } unsigned -#if NeedFunctionPrototypes XkbStateChangedFlags(XkbStatePtr old,XkbStatePtr new) -#else -XkbStateChangedFlags(old,new) - XkbStatePtr old; - XkbStatePtr new; -#endif { int changed; @@ -776,12 +672,7 @@ int changed; } void -#if NeedFunctionPrototypes XkbComputeCompatState(XkbSrvInfoPtr xkbi) -#else -XkbComputeCompatState(xkbi) - XkbSrvInfoPtr xkbi; -#endif { CARD16 grp_mask; XkbStatePtr state= &xkbi->state; @@ -799,13 +690,7 @@ XkbCompatMapPtr map; } unsigned -#if NeedFunctionPrototypes XkbAdjustGroup(int group,XkbControlsPtr ctrls) -#else -XkbAdjustGroup(group,ctrls) - int group; - XkbControlsPtr ctrls; -#endif { unsigned act; @@ -846,16 +731,11 @@ unsigned act; } void -#if NeedFunctionPrototypes XkbComputeDerivedState(XkbSrvInfoPtr xkbi) -#else -XkbComputeDerivedState(xkbi) - XkbSrvInfoPtr xkbi; -#endif { XkbStatePtr state= &xkbi->state; XkbControlsPtr ctrls= xkbi->desc->ctrls; -char grp; +unsigned char grp; state->mods= (state->base_mods|state->latched_mods); state->mods|= state->locked_mods; @@ -866,11 +746,11 @@ char grp; grp= state->locked_group; - if ((grp>=ctrls->num_groups) || (grp<0)) + if (grp>=ctrls->num_groups) state->locked_group= XkbAdjustGroup(grp,ctrls); grp= state->locked_group+state->base_group+state->latched_group; - if ((grp>=ctrls->num_groups) || (grp<0)) + if (grp>=ctrls->num_groups) state->group= XkbAdjustGroup(grp,ctrls); else state->group= grp; XkbComputeCompatState(xkbi); @@ -880,18 +760,10 @@ char grp; /***====================================================================***/ void -#if NeedFunctionPrototypes XkbCheckSecondaryEffects( XkbSrvInfoPtr xkbi, unsigned which, XkbChangesPtr changes, XkbEventCausePtr cause) -#else -XkbCheckSecondaryEffects(xkbi,which,changes,cause) - XkbSrvInfoPtr xkbi; - unsigned which; - XkbChangesPtr changes; - XkbEventCausePtr cause; -#endif { if (which&XkbStateNotifyMask) { XkbStateRec old; @@ -908,13 +780,7 @@ XkbCheckSecondaryEffects(xkbi,which,changes,cause) /***====================================================================***/ void -#if NeedFunctionPrototypes XkbSetPhysicalLockingKey(DeviceIntPtr dev,unsigned key) -#else -XkbSetPhysicalLockingKey(dev,key) - DeviceIntPtr dev; - unsigned key; -#endif { XkbDescPtr xkb; @@ -929,20 +795,11 @@ XkbDescPtr xkb; /***====================================================================***/ Bool -#if NeedFunctionPrototypes XkbEnableDisableControls( XkbSrvInfoPtr xkbi, unsigned long change, unsigned long newValues, XkbChangesPtr changes, XkbEventCausePtr cause) -#else -XkbEnableDisableControls(xkbi,change,newValues,changes,cause) - XkbSrvInfoPtr xkbi; - unsigned long change; - unsigned long newValues; - XkbChangesPtr changes; - XkbEventCausePtr cause; -#endif { XkbControlsPtr ctrls; unsigned old; @@ -987,14 +844,7 @@ XkbSrvLedInfoPtr sli; #define MAX_TOC 16 XkbGeometryPtr -#if NeedFunctionPrototypes XkbLookupNamedGeometry(DeviceIntPtr dev,Atom name,Bool *shouldFree) -#else -XkbLookupNamedGeometry(dev,name,shouldFree) - DeviceIntPtr dev; - Atom name; - Bool * shouldFree; -#endif { XkbSrvInfoPtr xkbi= dev->key->xkbInfo; XkbDescPtr xkb= xkbi->desc; @@ -1032,14 +882,7 @@ XkbDescPtr xkb= xkbi->desc; } void -#if NeedFunctionPrototypes XkbConvertCase(register KeySym sym, KeySym *lower, KeySym *upper) -#else -XkbConvertCase(sym, lower, upper) - register KeySym sym; - KeySym *lower; - KeySym *upper; -#endif { *lower = sym; *upper = sym; |