diff options
Diffstat (limited to 'src/xkb/XKBUse.c')
-rw-r--r-- | src/xkb/XKBUse.c | 189 |
1 files changed, 75 insertions, 114 deletions
diff --git a/src/xkb/XKBUse.c b/src/xkb/XKBUse.c index 1b564cc6..aea49cb6 100644 --- a/src/xkb/XKBUse.c +++ b/src/xkb/XKBUse.c @@ -24,6 +24,7 @@ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ********************************************************/ +/* $XFree86: xc/lib/X11/XKBUse.c,v 3.7 2003/07/07 15:34:21 eich Exp $ */ #include <stdio.h> #include <ctype.h> @@ -33,21 +34,10 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include <X11/extensions/XKBproto.h> #include "XKBlibint.h" -#ifdef X_NOT_STDC_ENV -extern char *getenv(); -#endif - static Bool _XkbIgnoreExtension = False; void -#if NeedFunctionPrototypes XkbNoteMapChanges(XkbMapChangesPtr old,XkbMapNotifyEvent *new,unsigned wanted) -#else -XkbNoteMapChanges(old,new,wanted) - XkbMapChangesPtr old; - XkbMapNotifyEvent * new; - unsigned int wanted; -#endif { int first,oldLast,newLast; wanted&= new->changed; @@ -186,16 +176,9 @@ XkbNoteMapChanges(old,new,wanted) } void -#if NeedFunctionPrototypes _XkbNoteCoreMapChanges( XkbMapChangesPtr old, XMappingEvent * new, unsigned int wanted) -#else -_XkbNoteCoreMapChanges(old,new,wanted) - XkbMapChangesPtr old; - XMappingEvent * new; - unsigned int wanted; -#endif { int first,oldLast,newLast; @@ -222,14 +205,7 @@ _XkbNoteCoreMapChanges(old,new,wanted) } static Bool -#if NeedFunctionPrototypes wire_to_event(Display *dpy,XEvent *re,xEvent *event) -#else -wire_to_event(dpy,re,event) - Display *dpy; - XEvent *re; - xEvent *event; -#endif { xkbEvent *xkbevent= (xkbEvent *)event; XkbInfoPtr xkbi; @@ -615,12 +591,7 @@ wire_to_event(dpy,re,event) } Bool -#if NeedFunctionPrototypes XkbIgnoreExtension(Bool ignore) -#else -XkbIgnoreExtension(ignore) - Bool ignore; -#endif { if (getenv("XKB_FORCE")!=NULL) { #ifdef DEBUG @@ -638,12 +609,7 @@ XkbIgnoreExtension(ignore) } static void -#if NeedFunctionPrototypes _XkbFreeInfo(Display *dpy) -#else -_XkbFreeInfo(dpy) - Display *dpy; -#endif { XkbInfoPtr xkbi = dpy->xkb_info; if (xkbi) { @@ -654,14 +620,7 @@ _XkbFreeInfo(dpy) } Bool -#if NeedFunctionPrototypes XkbUseExtension(Display *dpy,int *major_rtrn,int *minor_rtrn) -#else -XkbUseExtension(dpy,major_rtrn,minor_rtrn) - Display * dpy; - int * major_rtrn; - int * minor_rtrn; -#endif { xkbUseExtensionReply rep; register xkbUseExtensionReq *req; @@ -672,7 +631,7 @@ XkbUseExtension(dpy,major_rtrn,minor_rtrn) static int debugMsg; static int been_here= 0; - if ( dpy->xkb_info ) { + if ( dpy->xkb_info && !(dpy->flags & XlibDisplayNoXkb)) { if (major_rtrn) *major_rtrn= dpy->xkb_info->srv_major; if (minor_rtrn) *minor_rtrn= dpy->xkb_info->srv_minor; return True; @@ -685,8 +644,78 @@ XkbUseExtension(dpy,major_rtrn,minor_rtrn) if (major_rtrn) *major_rtrn= 0; if (minor_rtrn) *minor_rtrn= 0; + if (!dpy->xkb_info) { + xkbi = _XkbTypedCalloc(1, XkbInfoRec); + if ( !xkbi ) + return False; + dpy->xkb_info = xkbi; + dpy->free_funcs->xkb = _XkbFreeInfo; + + xkbi->xlib_ctrls|= (XkbLC_ControlFallback|XkbLC_ConsumeLookupMods); + if ((str=getenv("_XKB_OPTIONS_ENABLE"))!=NULL) { + if ((str=getenv("_XKB_LATIN1_LOOKUP"))!=NULL) { + if ((strcmp(str,"off")==0)||(strcmp(str,"0")==0)) + xkbi->xlib_ctrls&= ~XkbLC_ForceLatin1Lookup; + else xkbi->xlib_ctrls|= XkbLC_ForceLatin1Lookup; + } + if ((str=getenv("_XKB_CONSUME_LOOKUP_MODS"))!=NULL) { + if ((strcmp(str,"off")==0)||(strcmp(str,"0")==0)) + xkbi->xlib_ctrls&= ~XkbLC_ConsumeLookupMods; + else xkbi->xlib_ctrls|= XkbLC_ConsumeLookupMods; + } + if ((str=getenv("_XKB_CONSUME_SHIFT_AND_LOCK"))!=NULL) { + if ((strcmp(str,"off")==0)||(strcmp(str,"0")==0)) + xkbi->xlib_ctrls&= ~XkbLC_AlwaysConsumeShiftAndLock; + else xkbi->xlib_ctrls|= XkbLC_AlwaysConsumeShiftAndLock; + } + if ((str=getenv("_XKB_IGNORE_NEW_KEYBOARDS"))!=NULL) { + if ((strcmp(str,"off")==0)||(strcmp(str,"0")==0)) + xkbi->xlib_ctrls&= ~XkbLC_IgnoreNewKeyboards; + else xkbi->xlib_ctrls|= XkbLC_IgnoreNewKeyboards; + } + if ((str=getenv("_XKB_CONTROL_FALLBACK"))!=NULL) { + if ((strcmp(str,"off")==0)||(strcmp(str,"0")==0)) + xkbi->xlib_ctrls&= ~XkbLC_ControlFallback; + else xkbi->xlib_ctrls|= XkbLC_ControlFallback; + } + if ((str=getenv("_XKB_COMP_LED"))!=NULL) { + if ((strcmp(str,"off")==0)||(strcmp(str,"0")==0)) + xkbi->xlib_ctrls&= ~XkbLC_ComposeLED; + else { + xkbi->xlib_ctrls|= XkbLC_ComposeLED; + if (strlen(str)>0) + xkbi->composeLED= XInternAtom(dpy,str,False); + } + } + if ((str=getenv("_XKB_COMP_FAIL_BEEP"))!=NULL) { + if ((strcmp(str,"off")==0)||(strcmp(str,"0")==0)) + xkbi->xlib_ctrls&= ~XkbLC_BeepOnComposeFail; + else xkbi->xlib_ctrls|= XkbLC_BeepOnComposeFail; + } + } + if ((xkbi->composeLED==None)&&((xkbi->xlib_ctrls&XkbLC_ComposeLED)!=0)) + xkbi->composeLED= XInternAtom(dpy,"Compose",False); +#ifdef DEBUG + if (debugMsg) { + register unsigned c= xkbi->xlib_ctrls; + fprintf(stderr,"XKEYBOARD compose: beep on failure is %s, LED is %s\n", + ((c&XkbLC_BeepOnComposeFail)?"on":"off"), + ((c&XkbLC_ComposeLED)?"on":"off")); + fprintf(stderr,"XKEYBOARD XLookupString: %slatin-1, %s lookup modifiers\n", + ((c&XkbLC_ForceLatin1Lookup)?"allow non-":"force "), + ((c&XkbLC_ConsumeLookupMods)?"consume":"re-use")); + fprintf(stderr, + "XKEYBOARD XLookupString: %sconsume shift and lock, %scontrol fallback\n", + ((c&XkbLC_AlwaysConsumeShiftAndLock)?"always ":"don't "), + ((c&XkbLC_ControlFallback)?"":"no ")); + + } +#endif + } else + xkbi = dpy->xkb_info; + forceIgnore= (dpy->flags&XlibDisplayNoXkb)||dpy->keysyms; - forceIgnore= forceIgnore&(major_rtrn==NULL)&&(minor_rtrn==NULL); + forceIgnore= forceIgnore&&(major_rtrn==NULL)&&(minor_rtrn==NULL); if ( forceIgnore || _XkbIgnoreExtension || getenv("XKB_DISABLE")) { LockDisplay(dpy); dpy->flags |= XlibDisplayNoXkb; @@ -696,15 +725,10 @@ XkbUseExtension(dpy,major_rtrn,minor_rtrn) return False; } - xkbi = _XkbTypedCalloc(1, XkbInfoRec); - if ( !xkbi ) - return False; - if ( (codes=XInitExtension(dpy,XkbName))==NULL ) { LockDisplay(dpy); dpy->flags |= XlibDisplayNoXkb; UnlockDisplay(dpy); - Xfree(xkbi); if (debugMsg) fprintf(stderr,"XKEYBOARD extension not present\n"); return False; @@ -746,8 +770,7 @@ XkbUseExtension(dpy,major_rtrn,minor_rtrn) dpy->flags |= XlibDisplayNoXkb; UnlockDisplay(dpy); SyncHandle(); - Xfree(xkbi); - if (major_rtrn) *major_rtrn= rep.serverMajor; + if (major_rtrn) *major_rtrn= rep.serverMajor; if (minor_rtrn) *minor_rtrn= rep.serverMinor; return False; } @@ -766,70 +789,8 @@ XkbUseExtension(dpy,major_rtrn,minor_rtrn) fprintf(stderr,"XKEYBOARD (version %d.%02d/%d.%02d) OK!\n", XkbMajorVersion,XkbMinorVersion, rep.serverMajor,rep.serverMinor); - dpy->xkb_info = xkbi; - dpy->free_funcs->xkb = _XkbFreeInfo; - ev_base = codes->first_event; - xkbi->xlib_ctrls|= - (XkbLC_BeepOnComposeFail|XkbLC_ComposeLED|XkbLC_ControlFallback); - if ((str=getenv("_XKB_OPTIONS_ENABLE"))!=NULL) { - if ((str=getenv("_XKB_LATIN1_LOOKUP"))!=NULL) { - if ((strcmp(str,"off")==0)||(strcmp(str,"0")==0)) - xkbi->xlib_ctrls&= ~XkbLC_ForceLatin1Lookup; - else xkbi->xlib_ctrls|= XkbLC_ForceLatin1Lookup; - } - if ((str=getenv("_XKB_CONSUME_LOOKUP_MODS"))!=NULL) { - if ((strcmp(str,"off")==0)||(strcmp(str,"0")==0)) - xkbi->xlib_ctrls&= ~XkbLC_ConsumeLookupMods; - else xkbi->xlib_ctrls|= XkbLC_ConsumeLookupMods; - } - if ((str=getenv("_XKB_CONSUME_SHIFT_AND_LOCK"))!=NULL) { - if ((strcmp(str,"off")==0)||(strcmp(str,"0")==0)) - xkbi->xlib_ctrls&= ~XkbLC_AlwaysConsumeShiftAndLock; - else xkbi->xlib_ctrls|= XkbLC_AlwaysConsumeShiftAndLock; - } - if ((str=getenv("_XKB_IGNORE_NEW_KEYBOARDS"))!=NULL) { - if ((strcmp(str,"off")==0)||(strcmp(str,"0")==0)) - xkbi->xlib_ctrls&= ~XkbLC_IgnoreNewKeyboards; - else xkbi->xlib_ctrls|= XkbLC_IgnoreNewKeyboards; - } - if ((str=getenv("_XKB_CONTROL_FALLBACK"))!=NULL) { - if ((strcmp(str,"off")==0)||(strcmp(str,"0")==0)) - xkbi->xlib_ctrls&= ~XkbLC_ControlFallback; - else xkbi->xlib_ctrls|= XkbLC_ControlFallback; - } - if ((str=getenv("_XKB_COMP_LED"))!=NULL) { - if ((strcmp(str,"off")==0)||(strcmp(str,"0")==0)) - xkbi->xlib_ctrls&= ~XkbLC_ComposeLED; - else { - xkbi->xlib_ctrls|= XkbLC_ComposeLED; - if (strlen(str)>0) - xkbi->composeLED= XInternAtom(dpy,str,False); - } - } - if ((str=getenv("_XKB_COMP_FAIL_BEEP"))!=NULL) { - if ((strcmp(str,"off")==0)||(strcmp(str,"0")==0)) - xkbi->xlib_ctrls&= ~XkbLC_BeepOnComposeFail; - else xkbi->xlib_ctrls|= XkbLC_BeepOnComposeFail; - } - } - if ((xkbi->composeLED==None)&&((xkbi->xlib_ctrls&XkbLC_ComposeLED)!=0)) - xkbi->composeLED= XInternAtom(dpy,"Compose",False); -#ifdef DEBUG - if (debugMsg) { - register unsigned c= xkbi->xlib_ctrls; - fprintf(stderr,"XKEYBOARD compose: beep on failure is %s, LED is %s\n", - ((c&XkbLC_BeepOnComposeFail)?"on":"off"), - ((c&XkbLC_ComposeLED)?"on":"off")); - fprintf(stderr,"XKEYBOARD XLookupString: %slatin-1, %s lookup modifiers\n", - ((c&XkbLC_ForceLatin1Lookup)?"allow non-":"force "), - ((c&XkbLC_ConsumeLookupMods)?"consume":"re-use")); - fprintf(stderr, - "XKEYBOARD XLookupString: %sconsume shift and lock, %scontrol fallback\n", - ((c&XkbLC_AlwaysConsumeShiftAndLock)?"always ":"don't "), - ((c&XkbLC_ControlFallback)?"":"no ")); - } -#endif + ev_base = codes->first_event; XESetWireToEvent(dpy,ev_base+XkbEventCode,wire_to_event); SyncHandle(); return True; |