diff options
Diffstat (limited to 'xkb')
-rw-r--r-- | xkb/XKBAlloc.c | 1 | ||||
-rw-r--r-- | xkb/XKBGAlloc.c | 1 | ||||
-rw-r--r-- | xkb/XKBMAlloc.c | 1 | ||||
-rw-r--r-- | xkb/XKBMisc.c | 18 | ||||
-rw-r--r-- | xkb/ddxBeep.c | 29 | ||||
-rw-r--r-- | xkb/ddxConfig.c | 10 | ||||
-rw-r--r-- | xkb/ddxCtrls.c | 14 | ||||
-rw-r--r-- | xkb/ddxDevBtn.c | 3 | ||||
-rw-r--r-- | xkb/ddxFakeMtn.c | 92 | ||||
-rw-r--r-- | xkb/ddxKillSrv.c | 9 | ||||
-rw-r--r-- | xkb/ddxList.c | 21 | ||||
-rw-r--r-- | xkb/ddxLoad.c | 107 | ||||
-rw-r--r-- | xkb/ddxVT.c | 21 | ||||
-rw-r--r-- | xkb/maprules.c | 664 | ||||
-rw-r--r-- | xkb/xkb.c | 67 | ||||
-rw-r--r-- | xkb/xkbAccessX.c | 16 | ||||
-rw-r--r-- | xkb/xkbActions.c | 104 | ||||
-rw-r--r-- | xkb/xkbDflts.h | 203 | ||||
-rw-r--r-- | xkb/xkbEvents.c | 75 | ||||
-rw-r--r-- | xkb/xkbInit.c | 181 | ||||
-rw-r--r-- | xkb/xkbLEDs.c | 18 | ||||
-rw-r--r-- | xkb/xkbPrKeyEv.c | 55 | ||||
-rw-r--r-- | xkb/xkbSwap.c | 7 | ||||
-rw-r--r-- | xkb/xkbUtils.c | 19 | ||||
-rw-r--r-- | xkb/xkbconfig.c | 151 | ||||
-rw-r--r-- | xkb/xkberrs.c | 6 | ||||
-rw-r--r-- | xkb/xkbfmisc.c | 78 | ||||
-rw-r--r-- | xkb/xkbout.c | 18 | ||||
-rw-r--r-- | xkb/xkbtext.c | 15 | ||||
-rw-r--r-- | xkb/xkmread.c | 13 |
30 files changed, 1455 insertions, 562 deletions
diff --git a/xkb/XKBAlloc.c b/xkb/XKBAlloc.c index 82e98f4bc..c6fd855fe 100644 --- a/xkb/XKBAlloc.c +++ b/xkb/XKBAlloc.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/XKBAlloc.c,v 3.5 2001/01/17 19:41:48 dawes Exp $ */ #ifndef XKB_IN_SERVER diff --git a/xkb/XKBGAlloc.c b/xkb/XKBGAlloc.c index c89e1197c..44a74c6a8 100644 --- a/xkb/XKBGAlloc.c +++ b/xkb/XKBGAlloc.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/XKBGAlloc.c,v 3.4 2001/01/17 19:41:48 dawes Exp $ */ #define NEED_EVENTS #define NEED_REPLIES diff --git a/xkb/XKBMAlloc.c b/xkb/XKBMAlloc.c index ba2a70761..29cdc3c80 100644 --- a/xkb/XKBMAlloc.c +++ b/xkb/XKBMAlloc.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/XKBMAlloc.c,v 3.11 2001/01/17 19:41:48 dawes Exp $ */ #ifndef XKB_IN_SERVER diff --git a/xkb/XKBMisc.c b/xkb/XKBMisc.c index 45c00692a..f3de9295e 100644 --- a/xkb/XKBMisc.c +++ b/xkb/XKBMisc.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/XKBMisc.c,v 3.5 2001/10/28 03:32:33 tsi Exp $ */ #ifndef XKB_IN_SERVER @@ -54,12 +55,12 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #define mapSize(m) (sizeof(m)/sizeof(XkbKTMapEntryRec)) static XkbKTMapEntryRec map2Level[]= { - { True, ShiftMask, 1, ShiftMask, 0 } + { True, ShiftMask, {1, ShiftMask, 0} } }; static XkbKTMapEntryRec mapAlpha[]= { - { True, ShiftMask, 1, ShiftMask, 0 }, - { True, LockMask, 0, LockMask, 0 } + { True, ShiftMask, { 1, ShiftMask, 0 } }, + { True, LockMask, { 0, LockMask, 0 } } }; static XkbModsRec preAlpha[]= { @@ -69,8 +70,8 @@ static XkbModsRec preAlpha[]= { #define NL_VMOD_MASK 0 static XkbKTMapEntryRec mapKeypad[]= { - { True, ShiftMask, 1, ShiftMask, 0 }, - { False, 0, 1, 0, NL_VMOD_MASK } + { True, ShiftMask, { 1, ShiftMask, 0 } }, + { False, 0, { 1, 0, NL_VMOD_MASK } } }; static XkbKeyTypeRec canonicalTypes[XkbNumRequiredTypes] = { @@ -564,7 +565,7 @@ unsigned changed,tmp; if (((explicit&XkbExplicitAutoRepeatMask)==0)&&(xkb->ctrls)) { CARD8 old; old= xkb->ctrls->per_key_repeat[key/8]; -#if RETURN_SHOULD_REPEAT +#ifdef RETURN_SHOULD_REPEAT if (*XkbKeySymsPtr(xkb,key) != XK_Return) #endif xkb->ctrls->per_key_repeat[key/8]|= (1<<(key%8)); @@ -968,7 +969,7 @@ XkbApplyVirtualModChanges(xkb,changed,changes) #endif { register int i; -unsigned checkState; +unsigned int checkState = 0; if ((!xkb) || (!xkb->map) || (changed==0)) return False; @@ -1035,8 +1036,7 @@ unsigned checkState; } } if (xkb->map && xkb->server) { - int highChange,lowChange; - lowChange= -1; + int highChange = 0, lowChange = -1; for (i=xkb->min_key_code;i<=xkb->max_key_code;i++) { if (XkbKeyHasActions(xkb,i)) { register XkbAction *pAct; diff --git a/xkb/ddxBeep.c b/xkb/ddxBeep.c index 3f3ae57a0..74352161c 100644 --- a/xkb/ddxBeep.c +++ b/xkb/ddxBeep.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/programs/Xserver/xkb/ddxBeep.c,v 3.9 2002/12/05 21:59:00 paulo Exp $ */ #include <stdio.h> #define NEED_EVENTS 1 @@ -59,7 +60,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #define HIGH_PITCH 2000 #define CLICK_PITCH 1500 -static unsigned long atomGeneration= -1; +static unsigned long atomGeneration= 0; static Atom featureOn; static Atom featureOff; static Atom featureChange; @@ -138,6 +139,10 @@ _XkbDDXBeepInitAtoms() (strcmp(keyboard,"LK443") == 0)) doesPitch = 0; } +#else +#if defined(sun) + doesPitch = 0; +#endif #endif return; } @@ -317,7 +322,10 @@ Atom name; next = SHORT_DELAY; break; } - if (duration>0) { + if (timer == NULL && duration>0) { + CARD32 starttime = GetTimeInMillis(); + CARD32 elapsedtime; + ctrl->bell_duration= duration; ctrl->bell_pitch= pitch; if (xkbInfo->beepCount==0) { @@ -330,6 +338,23 @@ Atom name; ctrl->bell_duration= oldDuration; ctrl->bell_pitch= oldPitch; xkbInfo->beepCount++; + + /* Some DDX schedule the beep and return immediately, others don't + return until the beep is completed. We measure the time and if + it's less than the beep duration, make sure not to schedule the + next beep until after the current one finishes. */ + + elapsedtime = GetTimeInMillis(); + if (elapsedtime > starttime) { /* watch out for millisecond counter + overflow! */ + elapsedtime -= starttime; + } else { + elapsedtime = 0; + } + if (elapsedtime < duration) { + next += duration - elapsedtime; + } + } return next; } diff --git a/xkb/ddxConfig.c b/xkb/ddxConfig.c index f3635902f..58fc138bd 100644 --- a/xkb/ddxConfig.c +++ b/xkb/ddxConfig.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/programs/Xserver/xkb/ddxConfig.c,v 3.8 2002/12/20 20:18:35 paulo Exp $ */ #include <stdio.h> #define NEED_EVENTS 1 @@ -106,7 +107,6 @@ char buf[PATH_MAX]; char * dName; FILE * file; XkbConfigRtrnPtr rtrn; -extern char * display; #if defined(MetroLink) if (dev && dev->name) @@ -142,6 +142,9 @@ extern char * display; sprintf(buf,"X%s-config%s%s",display,(dName[0]?".":""),dName); } #endif +#ifdef __UNIXOS2__ + strcpy(buf,(char*)__XOS2RedirRoot(buf)); +#endif #ifdef DEBUG ErrorF("Looking for keyboard configuration in %s...",buf); #endif @@ -190,24 +193,29 @@ extern char * display; XkbSetRulesUsed(defs); if (rtrn->keycodes!=NULL) { + if (names->keycodes) _XkbFree(names->keycodes); names->keycodes= rtrn->keycodes; rtrn->keycodes= NULL; } if (rtrn->geometry!=NULL) { + if (names->geometry) _XkbFree(names->geometry); names->geometry= rtrn->geometry; rtrn->geometry= NULL; } if (rtrn->symbols!=NULL) { if (rtrn->phys_symbols==NULL) rtrn->phys_symbols= _XkbDupString(names->symbols); + if (names->symbols) _XkbFree(names->symbols); names->symbols= rtrn->symbols; rtrn->symbols= NULL; } if (rtrn->types!=NULL) { + if (names->types) _XkbFree(names->types); names->types= rtrn->types; rtrn->types= NULL; } if (rtrn->compat!=NULL) { + if (names->compat) _XkbFree(names->compat); names->compat= rtrn->compat; rtrn->compat= NULL; } diff --git a/xkb/ddxCtrls.c b/xkb/ddxCtrls.c index da599fbf2..4dfb03df2 100644 --- a/xkb/ddxCtrls.c +++ b/xkb/ddxCtrls.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/programs/Xserver/xkb/ddxCtrls.c,v 1.3 2001/01/17 22:37:14 dawes Exp $ */ #include <stdio.h> #define NEED_EVENTS 1 @@ -104,7 +105,8 @@ XkbDDXChangeControls(dev,old,new) XkbControlsPtr new; #endif { -unsigned changed; +unsigned changed, i; +unsigned char *rep_old, *rep_new, *rep_fb; changed= new->enabled_ctrls^old->enabled_ctrls; #ifdef NOTDEF @@ -124,6 +126,16 @@ unsigned changed; } } #endif + for (rep_old = old->per_key_repeat, + rep_new = new->per_key_repeat, + rep_fb = dev->kbdfeed->ctrl.autoRepeats, + i = 0; i < XkbPerKeyBitArraySize; i++) { + if (rep_old[i] != rep_new[i]) { + rep_fb[i] = rep_new[i]; + changed &= XkbPerKeyRepeatMask; + } + } + if (changed&XkbPerKeyRepeatMask) { if (dev->kbdfeed->CtrlProc) (*dev->kbdfeed->CtrlProc)(dev,&dev->kbdfeed->ctrl); diff --git a/xkb/ddxDevBtn.c b/xkb/ddxDevBtn.c index 7d641358f..47a757823 100644 --- a/xkb/ddxDevBtn.c +++ b/xkb/ddxDevBtn.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/programs/Xserver/xkb/ddxDevBtn.c,v 3.3 2001/08/23 21:49:51 tsi Exp $ */ #include <stdio.h> #define NEED_EVENTS 1 @@ -37,7 +38,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "XI.h" #include "XIproto.h" -extern int DeviceButtonPress,DeviceButtonRelease,DeviceValuator; +extern int DeviceValuator; void #if NeedFunctionPrototypes diff --git a/xkb/ddxFakeMtn.c b/xkb/ddxFakeMtn.c index 04a8c80e9..c92f2f1da 100644 --- a/xkb/ddxFakeMtn.c +++ b/xkb/ddxFakeMtn.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/programs/Xserver/xkb/ddxFakeMtn.c,v 1.4 2001/01/17 22:37:14 dawes Exp $ */ #include <stdio.h> #define NEED_EVENTS 1 @@ -36,12 +37,28 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "XKBsrv.h" #include "XI.h" +#ifdef PANORAMIX +#include "panoramiX.h" +#include "panoramiXsrv.h" +#endif + +#include "mipointer.h" +#include "mipointrst.h" + extern WindowPtr GetSpriteWindow( #if NeedFunctionPrototypes void #endif ); +extern void NewCurrentScreen( +#if NeedFunctionPrototypes + ScreenPtr /* newScreen */, + int /* x */, + int /* y */ +#endif +); + void #if NeedFunctionPrototypes XkbDDXFakePointerMotion(unsigned flags,int x,int y) @@ -52,25 +69,70 @@ XkbDDXFakePointerMotion(flags,x,y) int y; #endif { -ScreenPtr pScreen; int oldX,oldY; +ScreenPtr pScreen, oldScreen; - pScreen= GetSpriteWindow()->drawable.pScreen; - GetSpritePosition(&oldX,&oldY); - if (flags&XkbSA_MoveAbsoluteX) - oldX= x; - else oldX+= x; - if (flags&XkbSA_MoveAbsoluteY) - oldY= y; - else oldY+= y; + GetSpritePosition(&oldX, &oldY); + pScreen = oldScreen = GetSpriteWindow()->drawable.pScreen; - if (oldX<0) oldX= 0; - else if (oldX>=pScreen->width) oldX= pScreen->width-1; - if (oldY<0) oldY= 0; - else if (oldY>=pScreen->height) oldY= pScreen->height-1; +#ifdef PANORAMIX + if (!noPanoramiXExtension) { + BoxRec box; + int i; + if(!POINT_IN_REGION(pScreen, &XineramaScreenRegions[pScreen->myNum], + oldX, oldY, &box)) { + FOR_NSCREENS(i) { + if(i == pScreen->myNum) + continue; + if(POINT_IN_REGION(pScreen, &XineramaScreenRegions[i], + oldX, oldY, &box)) { + pScreen = screenInfo.screens[i]; + break; + } + } + } + oldScreen = pScreen; + + if (flags&XkbSA_MoveAbsoluteX) + oldX= x; + else oldX+= x; + if (flags&XkbSA_MoveAbsoluteY) + oldY= y; + else oldY+= y; + + if(!POINT_IN_REGION(pScreen, &XineramaScreenRegions[pScreen->myNum], + oldX, oldY, &box)) { + FOR_NSCREENS(i) { + if(i == pScreen->myNum) + continue; + if(POINT_IN_REGION(pScreen, &XineramaScreenRegions[i], + oldX, oldY, &box)) { + pScreen = screenInfo.screens[i]; + break; + } + } + } + oldX -= panoramiXdataPtr[pScreen->myNum].x; + oldY -= panoramiXdataPtr[pScreen->myNum].y; + } + else +#endif + { + if (flags&XkbSA_MoveAbsoluteX) + oldX= x; + else oldX+= x; + if (flags&XkbSA_MoveAbsoluteY) + oldY= y; + else oldY+= y; + +#define GetScreenPrivate(s) ((miPointerScreenPtr) ((s)->devPrivates[miPointerScreenIndex].ptr)) + (*(GetScreenPrivate(oldScreen))->screenFuncs->CursorOffScreen) + (&pScreen, &oldX, &oldY); + } + + if (pScreen != oldScreen) + NewCurrentScreen(pScreen, oldX, oldY); if (pScreen->SetCursorPosition) (*pScreen->SetCursorPosition)(pScreen, oldX, oldY, TRUE); - return; } - diff --git a/xkb/ddxKillSrv.c b/xkb/ddxKillSrv.c index 50fc9b24c..3c57f8786 100644 --- a/xkb/ddxKillSrv.c +++ b/xkb/ddxKillSrv.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/programs/Xserver/xkb/ddxKillSrv.c,v 1.3 2002/11/23 19:27:50 tsi Exp $ */ #include <stdio.h> #define NEED_EVENTS 1 @@ -36,6 +37,10 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "XKBsrv.h" #include "XI.h" +#ifdef XF86DDXACTIONS +#include "xf86.h" +#endif + int #if NeedFunctionPrototypes XkbDDXTerminateServer(DeviceIntPtr dev,KeyCode key,XkbAction *act) @@ -46,6 +51,10 @@ XkbDDXTerminateServer(dev,key,act) XkbAction *act; #endif { +#ifdef XF86DDXACTIONS + xf86ProcessActionEvent(ACTION_TERMINATE, NULL); +#else GiveUp(1); +#endif return 0; } diff --git a/xkb/ddxList.c b/xkb/ddxList.c index 9f1ad4406..8337022a3 100644 --- a/xkb/ddxList.c +++ b/xkb/ddxList.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/programs/Xserver/xkb/ddxList.c,v 3.7 2001/10/28 03:34:19 tsi Exp $ */ #include <stdio.h> #include <ctype.h> @@ -173,13 +174,13 @@ char tmpname[32]; +(xkbDebugFlags>9?2:1)+strlen(file)+31 > PATH_MAX) return BadImplementation; #ifndef WIN32 - sprintf(buf,"%s/xkbcomp -R%s/%s -w %d -l -vlfhpR '%s'", - XkbBaseDirectory,XkbBaseDirectory,componentDirs[what], + sprintf(buf,"%s/xkbcomp -R%s/%s -w %ld -l -vlfhpR '%s'", + XkbBaseDirectory,XkbBaseDirectory,componentDirs[what],(long) ((xkbDebugFlags<2)?1:((xkbDebugFlags>10)?10:xkbDebugFlags)), file); #else - sprintf(buf,"%s/xkbcomp -R%s/%s -w %d -l -vlfhpR '%s' %s", - XkbBaseDirectory,XkbBaseDirectory,componentDirs[what], + sprintf(buf,"%s/xkbcomp -R%s/%s -w %ld -l -vlfhpR '%s' %s", + XkbBaseDirectory,XkbBaseDirectory,componentDirs[what],(long) ((xkbDebugFlags<2)?1:((xkbDebugFlags>10)?10:xkbDebugFlags)), file, tmpname); #endif @@ -198,13 +199,13 @@ char tmpname[32]; +(xkbDebugFlags>9?2:1)+strlen(file)+29 > PATH_MAX) return BadImplementation; #ifndef WIN32 - sprintf(buf,"xkbcomp -R%s -w %d -l -vlfhpR '%s'", - componentDirs[what], + sprintf(buf,"xkbcomp -R%s -w %ld -l -vlfhpR '%s'", + componentDirs[what],(long) ((xkbDebugFlags<2)?1:((xkbDebugFlags>10)?10:xkbDebugFlags)), file); #else - sprintf(buf,"xkbcomp -R%s -w %d -l -vlfhpR '%s' %s", - componentDirs[what], + sprintf(buf,"xkbcomp -R%s -w %ld -l -vlfhpR '%s' %s", + componentDirs[what],(long) ((xkbDebugFlags<2)?1:((xkbDebugFlags>10)?10:xkbDebugFlags)), file, tmpname); #endif @@ -213,10 +214,10 @@ char tmpname[32]; status= Success; if (!haveDir) #ifndef WIN32 - in= popen(buf,"r"); + in= Popen(buf,"r"); #else { - if (system(buf) < 0) + if (System(buf) < 0) ErrorF("Could not invoke keymap compiler\n"); else in= fopen(tmpname, "r"); diff --git a/xkb/ddxLoad.c b/xkb/ddxLoad.c index 31b88a83f..82129d401 100644 --- a/xkb/ddxLoad.c +++ b/xkb/ddxLoad.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/programs/Xserver/xkb/ddxLoad.c,v 3.30 2002/05/31 18:46:06 dawes Exp $ */ #include <stdio.h> #include <ctype.h> @@ -40,7 +41,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "XKBsrv.h" #include "XI.h" -#if defined(CSRG_BASED) || defined(linux) || defined(__sgi) || defined(AIXV3) || defined(__osf__) +#if defined(CSRG_BASED) || defined(linux) || defined(__sgi) || defined(AIXV3) || defined(__osf__) || defined(__GNU__) #include <paths.h> #endif @@ -74,8 +75,9 @@ OutputDirectory (outdir) char* outdir; { #ifndef WIN32 - if (getuid() == 0 || geteuid() == 0) { - /* if server running as root it'll be able to write */ + if (getuid() == 0) { + /* if server running as root it *may* be able to write */ + /* FIXME: check whether directory is writable at all */ (void) strcpy (outdir, XKM_OUTPUT_DIR); } else #endif @@ -124,25 +126,41 @@ char cmd[PATH_MAX],file[PATH_MAX],xkm_output_dir[PATH_MAX],*map,*outFile; else outFile= _XkbDupString(file); XkbEnsureSafeMapName(outFile); OutputDirectory(xkm_output_dir); + if (XkbBaseDirectory!=NULL) { +#ifdef __UNIXOS2__ + char *tmpbase = (char*)__XOS2RedirRoot(XkbBaseDirectory); + int i; + if (strlen(tmpbase)*2+(xkbDebugFlags>9?2:1) +#else if (strlen(XkbBaseDirectory)*2+(xkbDebugFlags>9?2:1) +#endif +(map?strlen(map)+3:0)+strlen(PRE_ERROR_MSG) +strlen(ERROR_PREFIX)+strlen(POST_ERROR_MSG1) +strlen(file)+strlen(xkm_output_dir) +strlen(outFile)+53 > PATH_MAX) { -#ifdef DEBUG ErrorF("compiler command for keymap (%s) exceeds max length\n", names->keymap); -#endif return False; } +#ifndef __UNIXOS2__ sprintf(cmd,"%s/xkbcomp -w %d -R%s -xkm %s%s -em1 %s -emp %s -eml %s keymap/%s %s%s.xkm", XkbBaseDirectory, - ((xkbDebugFlags<2)?1:((xkbDebugFlags>10)?10:xkbDebugFlags)), + ((xkbDebugFlags<2)?1:((xkbDebugFlags>10)?10:(int)xkbDebugFlags)), XkbBaseDirectory,(map?"-m ":""),(map?map:""), PRE_ERROR_MSG,ERROR_PREFIX,POST_ERROR_MSG1,file, xkm_output_dir,outFile); +#else + for (i=0; i<strlen(tmpbase); i++) if (tmpbase[i]=='/') tmpbase[i]='\\'; + sprintf(cmd,"%s\\xkbcomp -w %d -R%s -xkm %s%s -em1 %s -emp %s -eml %s keymap/%s %s%s.xkm", + tmpbase, + ((xkbDebugFlags<2)?1:((xkbDebugFlags>10)?10:(int)xkbDebugFlags)), + tmpbase,(map?"-m ":""),(map?map:""), + PRE_ERROR_MSG,ERROR_PREFIX,POST_ERROR_MSG1,file, + xkm_output_dir,outFile); + ErrorF("Command line for XKB is %s\n",cmd); +#endif } else { if ((xkbDebugFlags>9?2:1)+(map?strlen(map)+3:0)+strlen(PRE_ERROR_MSG) @@ -150,14 +168,12 @@ char cmd[PATH_MAX],file[PATH_MAX],xkm_output_dir[PATH_MAX],*map,*outFile; +strlen(file)+strlen(xkm_output_dir) +strlen(outFile)+49 > PATH_MAX) { -#ifdef DEBUG ErrorF("compiler command for keymap (%s) exceeds max length\n", names->keymap); -#endif return False; } sprintf(cmd,"xkbcomp -w %d -xkm %s%s -em1 %s -emp %s -eml %s keymap/%s %s%s.xkm", - ((xkbDebugFlags<2)?1:((xkbDebugFlags>10)?10:xkbDebugFlags)), + ((xkbDebugFlags<2)?1:((xkbDebugFlags>10)?10:(int)xkbDebugFlags)), (map?"-m ":""),(map?map:""), PRE_ERROR_MSG,ERROR_PREFIX,POST_ERROR_MSG1,file, xkm_output_dir,outFile); @@ -168,20 +184,20 @@ char cmd[PATH_MAX],file[PATH_MAX],xkm_output_dir[PATH_MAX],*map,*outFile; ErrorF(" \"cmd\"\n"); } #endif - if (system(cmd)==0) { + if (System(cmd)==0) { if (nameRtrn) { strncpy(nameRtrn,outFile,nameRtrnLen); nameRtrn[nameRtrnLen-1]= '\0'; } if (outFile!=NULL) - Xfree(outFile); + _XkbFree(outFile); return True; } #ifdef DEBUG ErrorF("Error compiling keymap (%s)\n",names->keymap); #endif if (outFile!=NULL) - Xfree(outFile); + _XkbFree(outFile); return False; } @@ -208,11 +224,18 @@ char buf[PATH_MAX],keymap[PATH_MAX],xkm_output_dir[PATH_MAX]; #ifdef WIN32 char tmpname[32]; #endif +#ifdef __UNIXOS2__ +char *tmpbase; +int i; +#endif if ((names->keymap==NULL)||(names->keymap[0]=='\0')) { - extern char *display; sprintf(keymap,"server-%s",display); } else { + if (strlen(names->keymap) > PATH_MAX - 1) { + ErrorF("name of keymap (%s) exceeds max length\n", names->keymap); + return False; + } strcpy(keymap,names->keymap); } @@ -222,31 +245,43 @@ char tmpname[32]; strcpy(tmpname, "\\temp\\xkb_XXXXXX"); (void) mktemp(tmpname); #endif +#ifdef __UNIXOS2__ + tmpbase = (char*)__XOS2RedirRoot(XkbBaseDirectory); +#endif if (XkbBaseDirectory!=NULL) { if (strlen(XkbBaseDirectory)*2+(xkbDebugFlags>9?2:1) +strlen(PRE_ERROR_MSG)+strlen(ERROR_PREFIX) +strlen(POST_ERROR_MSG1)+strlen(xkm_output_dir) +strlen(keymap)+48 > PATH_MAX) { -#ifdef DEBUG ErrorF("compiler command for keymap (%s) exceeds max length\n", names->keymap); -#endif return False; } #ifndef WIN32 +#ifndef __UNIXOS2__ sprintf(buf, "%s/xkbcomp -w %d -R%s -xkm - -em1 %s -emp %s -eml %s \"%s%s.xkm\"", XkbBaseDirectory, - ((xkbDebugFlags<2)?1:((xkbDebugFlags>10)?10:xkbDebugFlags)), + ((xkbDebugFlags<2)?1:((xkbDebugFlags>10)?10:(int)xkbDebugFlags)), XkbBaseDirectory, PRE_ERROR_MSG,ERROR_PREFIX,POST_ERROR_MSG1, xkm_output_dir,keymap); #else + for (i=0; i<strlen(tmpbase); i++) if (tmpbase[i]=='/') tmpbase[i]='\\'; + sprintf(buf, + "%s\\xkbcomp -w %d -R%s -xkm - -em1 %s -emp %s -eml %s \"%s%s.xkm\"", + tmpbase, + ((xkbDebugFlags<2)?1:((xkbDebugFlags>10)?10:(int)xkbDebugFlags)), + tmpbase, + PRE_ERROR_MSG,ERROR_PREFIX,POST_ERROR_MSG1, + xkm_output_dir,keymap); +#endif +#else sprintf(buf, "%s/xkbcomp -w %d -R%s -xkm - -em1 %s -emp %s -eml %s \"%s%s.xkm\" < %s", XkbBaseDirectory, - ((xkbDebugFlags<2)?1:((xkbDebugFlags>10)?10:xkbDebugFlags)), + ((xkbDebugFlags<2)?1:((xkbDebugFlags>10)?10:(int)xkbDebugFlags)), XkbBaseDirectory, PRE_ERROR_MSG,ERROR_PREFIX,POST_ERROR_MSG1, xkm_output_dir,keymap,tmpname); @@ -257,28 +292,26 @@ char tmpname[32]; +strlen(ERROR_PREFIX)+strlen(POST_ERROR_MSG1) +strlen(xkm_output_dir)+strlen(keymap)+44 > PATH_MAX) { -#ifdef DEBUG ErrorF("compiler command for keymap (%s) exceeds max length\n", names->keymap); -#endif return False; } #ifndef WIN32 sprintf(buf, "xkbcomp -w %d -xkm - -em1 %s -emp %s -eml %s \"%s%s.xkm\"", - ((xkbDebugFlags<2)?1:((xkbDebugFlags>10)?10:xkbDebugFlags)), + ((xkbDebugFlags<2)?1:((xkbDebugFlags>10)?10:(int)xkbDebugFlags)), PRE_ERROR_MSG,ERROR_PREFIX,POST_ERROR_MSG1, xkm_output_dir,keymap); #else sprintf(buf, "xkbcomp -w %d -xkm - -em1 %s -emp %s -eml %s \"%s%s.xkm\" < %s", - ((xkbDebugFlags<2)?1:((xkbDebugFlags>10)?10:xkbDebugFlags)), + ((xkbDebugFlags<2)?1:((xkbDebugFlags>10)?10:(int)xkbDebugFlags)), PRE_ERROR_MSG,ERROR_PREFIX,POST_ERROR_MSG1, xkm_output_dir,keymap,tmpname); #endif } #ifndef WIN32 - out= popen(buf,"w"); + out= Popen(buf,"w"); #else out= fopen(tmpname, "w"); #endif @@ -291,13 +324,13 @@ char tmpname[32]; #endif XkbWriteXKBKeymapForNames(out,names,NULL,xkb,want,need); #ifndef WIN32 - if (pclose(out)==0) + if (Pclose(out)==0) #else if (fclose(out)==0) #endif { #ifdef WIN32 - if (system(buf) < 0) + if (System(buf) < 0) ErrorF("Could not invoke keymap compiler\n"); else { #endif @@ -305,6 +338,30 @@ char tmpname[32]; strncpy(nameRtrn,keymap,nameRtrnLen); nameRtrn[nameRtrnLen-1]= '\0'; } +#if defined(Lynx) && defined(__i386__) && defined(NEED_POPEN_WORKAROUND) + /* somehow popen/pclose is broken on LynxOS AT 2.3.0/2.4.0! + * the problem usually shows up with XF86Setup + * this hack waits at max 5 seconds after pclose() returns + * for the output of the xkbcomp output file. + * I didn't manage to get a patch in time for the 3.2 release + */ + { + int i; + char name[PATH_MAX]; + if (XkbBaseDirectory!=NULL) + sprintf(name,"%s/%s%s.xkm", XkbBaseDirectory + ,xkm_output_dir, keymap); + else + sprintf(name,"%s%s.xkm", xkm_output_dir, keymap); + for (i = 0; i < 10; i++) { + if (access(name, 0) == 0) break; + usleep(500000); + } +#ifdef DEBUG + if (i) ErrorF(">>>> Waited %d times for %s\n", i, name); +#endif + } +#endif return True; #ifdef WIN32 } @@ -493,3 +550,5 @@ XkbRF_RulesPtr rules; XkbRF_Free(rules,True); return complete; } + + diff --git a/xkb/ddxVT.c b/xkb/ddxVT.c index e1978d88b..58de4b207 100644 --- a/xkb/ddxVT.c +++ b/xkb/ddxVT.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/programs/Xserver/xkb/ddxVT.c,v 1.3 2002/11/23 19:27:50 tsi Exp $ */ #include <stdio.h> #define NEED_EVENTS 1 @@ -36,6 +37,10 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "XKBsrv.h" #include "XI.h" +#ifdef XF86DDXACTIONS +#include "xf86.h" +#endif + int #if NeedFunctionPrototypes XkbDDXSwitchScreen(DeviceIntPtr dev,KeyCode key,XkbAction *act) @@ -46,5 +51,21 @@ XkbDDXSwitchScreen(dev,key,act) XkbAction *act; #endif { +#ifdef XF86DDXACTIONS + { + int scrnnum = XkbSAScreen(&act->screen); + + if (act->screen.flags & XkbSA_SwitchApplication) { + if (act->screen.flags & XkbSA_SwitchAbsolute) + xf86ProcessActionEvent(ACTION_SWITCHSCREEN,(void *) &scrnnum); + else { + if (scrnnum < 0) + xf86ProcessActionEvent(ACTION_SWITCHSCREEN_PREV,NULL); + else + xf86ProcessActionEvent(ACTION_SWITCHSCREEN_NEXT,NULL); + } + } + } +#endif return 1; } diff --git a/xkb/maprules.c b/xkb/maprules.c index 559dc9c7f..8c5ce1a42 100644 --- a/xkb/maprules.c +++ b/xkb/maprules.c @@ -24,13 +24,11 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. ********************************************************/ +/* $XFree86: xc/lib/xkbfile/maprules.c,v 3.17 2002/11/26 01:43:25 dawes Exp $ */ #include <stdio.h> #include <ctype.h> -#ifndef X_NOT_STDC_ENV #include <stdlib.h> -#endif - #define X_INCLUDE_STRING_H #define XOS_USE_NO_LOCKING @@ -69,11 +67,13 @@ #endif #ifdef DEBUG -#define PR_DEBUG(s) fprintf(stderr,s) -#define PR_DEBUG1(s,a) fprintf(stderr,s,a) +#define PR_DEBUG(s) fprintf(stderr,s) +#define PR_DEBUG1(s,a) fprintf(stderr,s,a) +#define PR_DEBUG2(s,a,b) fprintf(stderr,s,a,b) #else #define PR_DEBUG(s) #define PR_DEBUG1(s,a) +#define PR_DEBUG2(s,a,b) #endif /***====================================================================***/ @@ -254,8 +254,12 @@ static char * cname[MAX_WORDS] = { }; typedef struct _RemapSpec { + int number; int num_remap; - int remap[MAX_WORDS]; + struct { + int word; + int index; + } remap[MAX_WORDS]; } RemapSpec; typedef struct _FileSpec { @@ -263,8 +267,49 @@ typedef struct _FileSpec { struct _FileSpec * pending; } FileSpec; +typedef struct { + char * model; + char * layout[XkbNumKbdGroups+1]; + char * variant[XkbNumKbdGroups+1]; + char * options; +} XkbRF_MultiDefsRec, *XkbRF_MultiDefsPtr; + +#define NDX_BUFF_SIZE 4 + /***====================================================================***/ +static char* +#if NeedFunctionPrototypes +get_index(char *str, int *ndx) +#else +get_index(str, ndx) + char *str; + int *ndx; +#endif +{ + char ndx_buf[NDX_BUFF_SIZE]; + char *end; + + if (*str != '[') { + *ndx = 0; + return str; + } + str++; + end = strchr(str, ']'); + if (end == NULL) { + *ndx = -1; + return str - 1; + } + if ( (end - str) >= NDX_BUFF_SIZE) { + *ndx = -1; + return end + 1; + } + strncpy(ndx_buf, str, end - str); + ndx_buf[end - str] = '\0'; + *ndx = atoi(ndx_buf); + return end + 1; +} + static void #if NeedFunctionPrototypes SetUpRemap(InputLine *line,RemapSpec *remap) @@ -275,16 +320,20 @@ SetUpRemap(line,remap) #endif { char * tok,*str; -unsigned present; +unsigned present, l_ndx_present, v_ndx_present; register int i; +int len, ndx; +_Xstrtokparams strtok_buf; #ifdef DEBUG Bool found; #endif -_Xstrtokparams strtok_buf; - present= 0; + + l_ndx_present = v_ndx_present = present= 0; str= &line->line[1]; + len = remap->number; bzero((char *)remap,sizeof(RemapSpec)); + remap->number = len; while ((tok=_XStrtok(str," ",strtok_buf))!=NULL) { #ifdef DEBUG found= False; @@ -293,17 +342,40 @@ _Xstrtokparams strtok_buf; if (strcmp(tok,"=")==0) continue; for (i=0;i<MAX_WORDS;i++) { - if (strcmp(cname[i],tok)==0) { + len = strlen(cname[i]); + if (strncmp(cname[i],tok,len)==0) { + if(strlen(tok) > len) { + char *end = get_index(tok+len, &ndx); + if ((i != LAYOUT && i != VARIANT) || + *end != '\0' || ndx == -1) + break; + if (ndx < 1 || ndx > XkbNumKbdGroups) { + PR_DEBUG2("Illegal %s index: %d\n", cname[i], ndx); + PR_DEBUG1("Index must be in range 1..%d\n", + XkbNumKbdGroups); + break; + } + } else { + ndx = 0; + } #ifdef DEBUG found= True; #endif if (present&(1<<i)) { - PR_DEBUG1("Component \"%s\" listed twice\n",tok); - PR_DEBUG("Second definition ignored\n"); - break; + if ((i == LAYOUT && l_ndx_present&(1<<ndx)) || + (i == VARIANT && v_ndx_present&(1<<ndx)) ) { + PR_DEBUG1("Component \"%s\" listed twice\n",tok); + PR_DEBUG("Second definition ignored\n"); + break; + } } - present|= (1<<i); - remap->remap[remap->num_remap++]= i; + present |= (1<<i); + if (i == LAYOUT) + l_ndx_present |= 1 << ndx; + if (i == VARIANT) + v_ndx_present |= 1 << ndx; + remap->remap[remap->num_remap].word= i; + remap->remap[remap->num_remap++].index= ndx; break; } } @@ -316,8 +388,8 @@ _Xstrtokparams strtok_buf; if ((present&PART_MASK)==0) { #ifdef DEBUG unsigned mask= PART_MASK; - fprintf(stderr,"Mapping needs at one of "); - for (i=0;(i<MAX_WORDS)&mask;i++) { + fprintf(stderr,"Mapping needs at least one of "); + for (i=0; (i<MAX_WORDS); i++) { if ((1L<<i)&mask) { mask&= ~(1L<<i); if (mask) fprintf(stderr,"\"%s,\" ",cname[i]); @@ -349,6 +421,7 @@ _Xstrtokparams strtok_buf; remap->num_remap= 0; return; } + remap->number++; return; } @@ -386,23 +459,52 @@ static Bool #if NeedFunctionPrototypes CheckLine( InputLine * line, RemapSpec * remap, - XkbRF_RulePtr rule) + XkbRF_RulePtr rule, + XkbRF_GroupPtr group) #else -CheckLine(line,remap,rule) +CheckLine(line,remap,rule,group) InputLine * line; RemapSpec * remap; XkbRF_RulePtr rule; + XkbRF_GroupsPtr group; #endif { char * str,*tok; -register int nread; +register int nread, i; FileSpec tmp; _Xstrtokparams strtok_buf; +Bool append = False; if (line->line[0]=='!') { - SetUpRemap(line,remap); - return False; + if (line->line[1] == '$' || + (line->line[1] == ' ' && line->line[2] == '$')) { + char *gname = strchr(line->line, '$'); + char *words = strchr(gname, ' '); + if(!words) + return False; + *words++ = '\0'; + for (; *words; words++) { + if (*words != '=' && *words != ' ') + break; + } + if (*words == '\0') + return False; + group->name = _XkbDupString(gname); + group->words = _XkbDupString(words); + for (i = 1, words = group->words; *words; words++) { + if ( *words == ' ') { + *words++ = '\0'; + i++; + } + } + group->number = i; + return True; + } else { + SetUpRemap(line,remap); + return False; + } } + if (remap->num_remap==0) { PR_DEBUG("Must have a mapping before first line of data\n"); PR_DEBUG("Illegal line of data ignored\n"); @@ -421,23 +523,24 @@ _Xstrtokparams strtok_buf; PR_DEBUG1("Extra word \"%s\" ignored\n",tok); continue; } - tmp.name[remap->remap[nread]]= tok; + tmp.name[remap->remap[nread].word]= tok; + if (*tok == '+' || *tok == '|') + append = True; } if (nread<remap->num_remap) { - PR_DEBUG("Too few words on a line\n"); + PR_DEBUG1("Too few words on a line: %s\n", line->line); PR_DEBUG("line ignored\n"); return False; } - if ((tmp.name[MODEL]!=NULL)&&(strcmp(tmp.name[MODEL],"*")==0)) - tmp.name[MODEL]= NULL; - if ((tmp.name[LAYOUT]!=NULL)&&(strcmp(tmp.name[LAYOUT],"*")==0)) - tmp.name[LAYOUT]= NULL; - if ((tmp.name[VARIANT]!=NULL)&&(strcmp(tmp.name[VARIANT],"*")==0)) - tmp.name[VARIANT]= NULL; rule->flags= 0; + rule->number = remap->number; if (tmp.name[OPTION]) - rule->flags|= XkbRF_Delayed|XkbRF_Append; + rule->flags|= XkbRF_Option; + else if (append) + rule->flags|= XkbRF_Append; + else + rule->flags|= XkbRF_Normal; rule->model= _XkbDupString(tmp.name[MODEL]); rule->layout= _XkbDupString(tmp.name[LAYOUT]); rule->variant= _XkbDupString(tmp.name[VARIANT]); @@ -449,6 +552,16 @@ _Xstrtokparams strtok_buf; rule->compat= _XkbDupString(tmp.name[COMPAT]); rule->geometry= _XkbDupString(tmp.name[GEOMETRY]); rule->keymap= _XkbDupString(tmp.name[KEYMAP]); + + rule->layout_num = rule->variant_num = 0; + for (i = 0; i < nread; i++) { + if (remap->remap[i].index) { + if (remap->remap[i].word == LAYOUT) + rule->layout_num = remap->remap[i].index; + if (remap->remap[i].word == VARIANT) + rule->variant_num = remap->remap[i].index; + } + } return True; } @@ -465,14 +578,127 @@ int len; if ((!str1)||(!str2)) return str1; - len= strlen(str1)+strlen(str2)+1; + len= strlen(str1)+strlen(str2)+1; str1= _XkbTypedRealloc(str1,len,char); if (str1) strcat(str1,str2); return str1; } -Bool +static void +#if NeedFunctionPrototypes +squeeze_spaces(char *p1) +#else +squeeze_spaces(p1) + char *p1; +#endif +{ + char *p2; + for (p2 = p1; *p2; p2++) { + *p1 = *p2; + if (*p1 != ' ') p1++; + } + *p1 = '\0'; +} + +static Bool +#if NeedFunctionPrototypes +MakeMultiDefs(XkbRF_MultiDefsPtr mdefs, XkbRF_VarDefsPtr defs) +#else +MakeMultiDefs(mdefs, defs) + XkbRF_MultiDefsPtr mdefs + XkbRF_VarDefsPtr defs; +#endif +{ + + bzero((char *)mdefs,sizeof(XkbRF_MultiDefsRec)); + mdefs->model = defs->model; + mdefs->options = _XkbDupString(defs->options); + if (mdefs->options) squeeze_spaces(mdefs->options); + + if (defs->layout) { + if (!strchr(defs->layout, ',')) { + mdefs->layout[0] = defs->layout; + } else { + char *p; + int i; + mdefs->layout[1] = _XkbDupString(defs->layout); + if (mdefs->layout[1] == NULL) + return False; + squeeze_spaces(mdefs->layout[1]); + p = mdefs->layout[1]; + for (i = 2; i <= XkbNumKbdGroups; i++) { + if ((p = strchr(p, ','))) { + *p++ = '\0'; + mdefs->layout[i] = p; + } else { + break; + } + } + if (p && (p = strchr(p, ','))) + *p = '\0'; + } + } + + if (defs->variant) { + if (!strchr(defs->variant, ',')) { + mdefs->variant[0] = defs->variant; + } else { + char *p; + int i; + mdefs->variant[1] = _XkbDupString(defs->variant); + if (mdefs->variant[1] == NULL) + return False; + squeeze_spaces(mdefs->variant[1]); + p = mdefs->variant[1]; + for (i = 2; i <= XkbNumKbdGroups; i++) { + if ((p = strchr(p, ','))) { + *p++ = '\0'; + mdefs->variant[i] = p; + } else { + break; + } + } + if (p && (p = strchr(p, ','))) + *p = '\0'; + } + } + return True; +} + +static void +#if NeedFunctionPrototypes +FreeMultiDefs(XkbRF_MultiDefsPtr defs) +#else +FreeMultiDefs(defs) + XkbRF_MultiDefsPtr defs; +#endif +{ + if (defs->options) _XkbFree(defs->options); + if (defs->layout[1]) _XkbFree(defs->layout[1]); + if (defs->variant[1]) _XkbFree(defs->variant[1]); +} + +static void +#if NeedFunctionPrototypes +Apply(char *src, char **dst) +#else +Apply(src, dst) + char *src; + char *dst; +#endif +{ + if (src) { + if (*src == '+' || *src == '!') { + *dst= _Concat(*dst, src); + } else { + if (*dst == NULL) + *dst= _XkbDupString(src); + } + } +} + +static void #if NeedFunctionPrototypes XkbRF_ApplyRule( XkbRF_RulePtr rule, XkbComponentNamesPtr names) @@ -483,86 +709,129 @@ XkbRF_ApplyRule(rule,names) #endif { rule->flags&= ~XkbRF_PendingMatch; /* clear the flag because it's applied */ - if ((rule->flags&XkbRF_Append)==0) { - if ((names->keycodes==NULL)&&(rule->keycodes!=NULL)) - names->keycodes= _XkbDupString(rule->keycodes); - - if ((names->symbols==NULL)&&(rule->symbols!=NULL)) - names->symbols= _XkbDupString(rule->symbols); - - if ((names->types==NULL)&&(rule->types!=NULL)) - names->types= _XkbDupString(rule->types); - if ((names->compat==NULL)&&(rule->compat!=NULL)) - names->compat= _XkbDupString(rule->compat); - - if ((names->geometry==NULL)&&(rule->geometry!=NULL)) - names->geometry= _XkbDupString(rule->geometry); - - if ((names->keymap==NULL)&&(rule->keymap!=NULL)) - names->keymap= _XkbDupString(rule->keymap); - } - else { - if (rule->keycodes) - names->keycodes= _Concat(names->keycodes,rule->keycodes); - if (rule->symbols) - names->symbols= _Concat(names->symbols,rule->symbols); - if (rule->types) - names->types= _Concat(names->types,rule->types); - if (rule->compat) - names->compat= _Concat(names->compat,rule->compat); - if (rule->geometry) - names->geometry= _Concat(names->geometry,rule->geometry); - if (rule->keymap) - names->keymap= _Concat(names->keymap,rule->keymap); - } - return (names->keycodes && names->symbols && names->types && - names->compat && names->geometry ) || names->keymap; + Apply(rule->keycodes, &names->keycodes); + Apply(rule->symbols, &names->symbols); + Apply(rule->types, &names->types); + Apply(rule->compat, &names->compat); + Apply(rule->geometry, &names->geometry); + Apply(rule->keymap, &names->keymap); } -#define CHECK_MATCH(r,d) ((((r)[0]=='?')&&((r)[1]=='\0'))||(strcmp(r,d)==0)) +static Bool +#if NeedFunctionPrototypes +CheckGroup( XkbRF_RulesPtr rules, + char * group_name, + char * name) +#else +XkbRF_CheckApplyRule(rules,group,name) + XkbRF_RulesPtr rules; + char * group_name; + char * name; +#endif +{ + int i; + char *p; + XkbRF_GroupPtr group; + + for (i = 0, group = rules->groups; i < rules->num_groups; i++, group++) { + if (! strcmp(group->name, group_name)) { + break; + } + } + if (i == rules->num_groups) + return False; + for (i = 0, p = group->words; i < group->number; i++, p += strlen(p)+1) { + if (! strcmp(p, name)) { + return True; + } + } + return False; +} -Bool +static int #if NeedFunctionPrototypes XkbRF_CheckApplyRule( XkbRF_RulePtr rule, - XkbRF_VarDefsPtr defs, - XkbComponentNamesPtr names) + XkbRF_MultiDefsPtr mdefs, + XkbComponentNamesPtr names, + XkbRF_RulesPtr rules) #else -XkbRF_CheckApplyRule(rule,defs,names) +XkbRF_CheckApplyRule(rule,mdefs,names) XkbRF_RulePtr rule; - XkbRF_VarDefsPtr defs; + XkbRF_MultiDefsPtr mdefs; XkbComponentNamesPtr names; + XkbRF_RulesPtr rules; #endif { - if (rule->model!=NULL) { - if ((!defs->model)||(!CHECK_MATCH(rule->model,defs->model))) - return False; + Bool pending = False; + + if (rule->model != NULL) { + if(mdefs->model == NULL) + return 0; + if (strcmp(rule->model, "*") == 0) { + pending = True; + } else { + if (rule->model[0] == '$') { + if (!CheckGroup(rules, rule->model, mdefs->model)) + return 0; + } else { + if (strcmp(rule->model, mdefs->model) != 0) + return 0; + } + } } - if (rule->layout!=NULL) { - if ((!defs->layout)||(!CHECK_MATCH(rule->layout,defs->layout))) - return False; + if (rule->option != NULL) { + if (mdefs->options == NULL) + return 0; + if ((!MatchOneOf(rule->option,mdefs->options))) + return 0; } - if (rule->variant!=NULL) { - if ((!defs->variant)||(!CHECK_MATCH(rule->variant,defs->variant))) - return False; + + if (rule->layout != NULL) { + if(mdefs->layout[rule->layout_num] == NULL || + *mdefs->layout[rule->layout_num] == '\0') + return 0; + if (strcmp(rule->layout, "*") == 0) { + pending = True; + } else { + if (rule->layout[0] == '$') { + if (!CheckGroup(rules, rule->layout, + mdefs->layout[rule->layout_num])) + return 0; + } else { + if (strcmp(rule->layout, mdefs->layout[rule->layout_num]) != 0) + return 0; + } + } } - if (rule->option!=NULL) { - if ((!defs->options)||(!MatchOneOf(rule->option,defs->options))) - return False; + if (rule->variant != NULL) { + if (mdefs->variant[rule->variant_num] == NULL || + *mdefs->variant[rule->variant_num] == '\0') + return 0; + if (strcmp(rule->variant, "*") == 0) { + pending = True; + } else { + if (rule->variant[0] == '$') { + if (!CheckGroup(rules, rule->variant, + mdefs->variant[rule->variant_num])) + return 0; + } else { + if (strcmp(rule->variant, + mdefs->variant[rule->variant_num]) != 0) + return 0; + } + } } - - if ((!rule->option)&& - ((!rule->model)||(!rule->layout)||(!rule->variant))) { - /* partial map -- partial maps are applied in the order they */ - /* appear, but all partial maps come before any options. */ - rule->flags|= XkbRF_PendingMatch; - return False; + if (pending) { + rule->flags|= XkbRF_PendingMatch; + return rule->number; } /* exact match, apply it now */ - return XkbRF_ApplyRule(rule,names); + XkbRF_ApplyRule(rule,names); + return rule->number; } -void +static void #if NeedFunctionPrototypes XkbRF_ClearPartialMatches(XkbRF_RulesPtr rules) #else @@ -578,7 +847,7 @@ XkbRF_RulePtr rule; } } -Bool +static void #if NeedFunctionPrototypes XkbRF_ApplyPartialMatches(XkbRF_RulesPtr rules,XkbComponentNamesPtr names) #else @@ -589,78 +858,57 @@ XkbRF_ApplyPartialMatches(rules,names) { int i; XkbRF_RulePtr rule; -Bool complete; - complete= False; - for (rule=rules->rules,i=0;(i<rules->num_rules)&&(!complete);i++,rule++) { + for (rule = rules->rules, i = 0; i < rules->num_rules; i++, rule++) { if ((rule->flags&XkbRF_PendingMatch)==0) continue; - complete= XkbRF_ApplyRule(rule,names); - } - return complete; -} - -void -#if NeedFunctionPrototypes -XkbRF_CheckApplyDelayedRules( XkbRF_RulesPtr rules, - XkbRF_VarDefsPtr defs, - XkbComponentNamesPtr names) -#else -XkbRF_CheckApplyDelayedRules(rules,defs,names) - XkbRF_RulesPtr rules; - XkbRF_VarDefsPtr defs; - XkbComponentNamesPtr names; -#endif -{ -int i; -XkbRF_RulePtr rule; - - for (rule=rules->rules,i=0;(i<rules->num_rules);i++,rule++) { - if ((rule->flags&XkbRF_Delayed)==0) - continue; - XkbRF_CheckApplyRule(rule,defs,names); + XkbRF_ApplyRule(rule,names); } - return; } -Bool +static void #if NeedFunctionPrototypes XkbRF_CheckApplyRules( XkbRF_RulesPtr rules, - XkbRF_VarDefsPtr defs, - XkbComponentNamesPtr names) + XkbRF_MultiDefsPtr mdefs, + XkbComponentNamesPtr names, + int flags) #else -XkbRF_CheckApplyRules(rules,defs,names) +XkbRF_CheckApplyRules(rules, mdefs, names, flags) XkbRF_RulesPtr rules; - XkbRF_VarDefsPtr defs; + XkbRF_MultiDefsPtr mdefs; XkbComponentNamesPtr names; + int flags; #endif { int i; XkbRF_RulePtr rule; -Bool complete; +int skip; - complete= False; - for (rule=rules->rules,i=0;(i<rules->num_rules)&&(!complete);i++,rule++) { - if ((rule->flags&XkbRF_Delayed)!=0) + for (rule = rules->rules, i=0; i < rules->num_rules; rule++, i++) { + if ((rule->flags & flags) != flags) continue; - complete= XkbRF_CheckApplyRule(rule,defs,names); + skip = XkbRF_CheckApplyRule(rule, mdefs, names, rules); + if (skip && !(flags & XkbRF_Option)) { + for ( ;(i < rules->num_rules) && (rule->number == skip); + rule++, i++); + rule--; i--; + } } - return complete; } /***====================================================================***/ -char * +static char * #if NeedFunctionPrototypes -XkbRF_SubstituteVars(char *name,XkbRF_VarDefsPtr defs) +XkbRF_SubstituteVars(char *name, XkbRF_MultiDefsPtr mdefs) #else -XkbRF_SubstituteVars(name,defs) +XkbRF_SubstituteVars(name, mdefs) char * name; - XkbRF_VarDefsPtr defs; + XkbRF_MultiDefsPtr mdefs; #endif { -char *str,*outstr,*orig; -int len; +char *str, *outstr, *orig, *var; +int len, ndx; orig= name; str= index(name,'%'); @@ -678,17 +926,22 @@ int len; extra_len= 2; str++; } - - if ((str[1]=='l')&&defs->layout) - len+= strlen(defs->layout)+extra_len; - else if ((str[1]=='m')&&defs->model) - len+= strlen(defs->model)+extra_len; - else if ((str[1]=='v')&&defs->variant) - len+= strlen(defs->variant)+extra_len; - if ((pfx=='(')&&(str[2]==')')) { + var = str + 1; + str = get_index(var + 1, &ndx); + if (ndx == -1) { + str = index(str,'%'); + continue; + } + if ((*var=='l') && mdefs->layout[ndx] && *mdefs->layout[ndx]) + len+= strlen(mdefs->layout[ndx])+extra_len; + else if ((*var=='m')&&mdefs->model) + len+= strlen(mdefs->model)+extra_len; + else if ((*var=='v') && mdefs->variant[ndx] && *mdefs->variant[ndx]) + len+= strlen(mdefs->variant[ndx])+extra_len; + if ((pfx=='(')&&(*str==')')) { str++; } - str= index(&str[1],'%'); + str= index(&str[0],'%'); } name= (char *)_XkbAlloc(len+1); str= orig; @@ -708,26 +961,30 @@ int len; } else pfx= '\0'; - if ((str[0]=='l')&&(defs->layout)) { + var = str; + str = get_index(var + 1, &ndx); + if (ndx == -1) { + continue; + } + if ((*var=='l') && mdefs->layout[ndx] && *mdefs->layout[ndx]) { if (pfx) *outstr++= pfx; - strcpy(outstr,defs->layout); - outstr+= strlen(defs->layout); + strcpy(outstr,mdefs->layout[ndx]); + outstr+= strlen(mdefs->layout[ndx]); if (sfx) *outstr++= sfx; } - else if ((str[0]=='m')&&(defs->model)) { + else if ((*var=='m')&&(mdefs->model)) { if (pfx) *outstr++= pfx; - strcpy(outstr,defs->model); - outstr+= strlen(defs->model); + strcpy(outstr,mdefs->model); + outstr+= strlen(mdefs->model); if (sfx) *outstr++= sfx; } - else if ((str[0]=='v')&&(defs->variant)) { + else if ((*var=='v') && mdefs->variant[ndx] && *mdefs->variant[ndx]) { if (pfx) *outstr++= pfx; - strcpy(outstr,defs->variant); - outstr+= strlen(defs->variant); + strcpy(outstr,mdefs->variant[ndx]); + outstr+= strlen(mdefs->variant[ndx]); if (sfx) *outstr++= sfx; } - str++; - if ((pfx=='(')&&(str[0]==')')) + if ((pfx=='(')&&(*str==')')) str++; } else { @@ -754,26 +1011,32 @@ XkbRF_GetComponents(rules,defs,names) XkbComponentNamesPtr names; #endif { -Bool complete; + XkbRF_MultiDefsRec mdefs; + + MakeMultiDefs(&mdefs, defs); bzero((char *)names,sizeof(XkbComponentNamesRec)); XkbRF_ClearPartialMatches(rules); - complete= XkbRF_CheckApplyRules(rules,defs,names); - if (!complete) - complete= XkbRF_ApplyPartialMatches(rules,names); - XkbRF_CheckApplyDelayedRules(rules,defs,names); + XkbRF_CheckApplyRules(rules, &mdefs, names, XkbRF_Normal); + XkbRF_ApplyPartialMatches(rules, names); + XkbRF_CheckApplyRules(rules, &mdefs, names, XkbRF_Append); + XkbRF_ApplyPartialMatches(rules, names); + XkbRF_CheckApplyRules(rules, &mdefs, names, XkbRF_Option); + if (names->keycodes) - names->keycodes= XkbRF_SubstituteVars(names->keycodes,defs); + names->keycodes= XkbRF_SubstituteVars(names->keycodes, &mdefs); if (names->symbols) - names->symbols= XkbRF_SubstituteVars(names->symbols,defs); + names->symbols= XkbRF_SubstituteVars(names->symbols, &mdefs); if (names->types) - names->types= XkbRF_SubstituteVars(names->types,defs); + names->types= XkbRF_SubstituteVars(names->types, &mdefs); if (names->compat) - names->compat= XkbRF_SubstituteVars(names->compat,defs); + names->compat= XkbRF_SubstituteVars(names->compat, &mdefs); if (names->geometry) - names->geometry= XkbRF_SubstituteVars(names->geometry,defs); + names->geometry= XkbRF_SubstituteVars(names->geometry, &mdefs); if (names->keymap) - names->keymap= XkbRF_SubstituteVars(names->keymap,defs); + names->keymap= XkbRF_SubstituteVars(names->keymap, &mdefs); + + FreeMultiDefs(&mdefs); return (names->keycodes && names->symbols && names->types && names->compat && names->geometry ) || names->keymap; } @@ -807,6 +1070,33 @@ XkbRF_AddRule(rules) return &rules->rules[rules->num_rules++]; } +XkbRF_GroupPtr +#if NeedFunctionPrototypes +XkbRF_AddGroup(XkbRF_RulesPtr rules) +#else +XkbRF_AddGroup(rules) + XkbRF_RulesPtr rules; +#endif +{ + if (rules->sz_groups<1) { + rules->sz_groups= 16; + rules->num_groups= 0; + rules->groups= _XkbTypedCalloc(rules->sz_groups,XkbRF_GroupRec); + } + else if (rules->num_groups >= rules->sz_groups) { + rules->sz_groups *= 2; + rules->groups= _XkbTypedRealloc(rules->groups,rules->sz_groups, + XkbRF_GroupRec); + } + if (!rules->groups) { + rules->sz_groups= rules->num_groups= 0; + return NULL; + } + + bzero((char *)&rules->groups[rules->num_groups],sizeof(XkbRF_GroupRec)); + return &rules->groups[rules->num_groups++]; +} + Bool #if NeedFunctionPrototypes XkbRF_LoadRules(FILE *file, XkbRF_RulesPtr rules) @@ -819,16 +1109,25 @@ XkbRF_LoadRules(file,rules) InputLine line; RemapSpec remap; XkbRF_RuleRec trule,*rule; +XkbRF_GroupRec tgroup,*group; if (!(rules && file)) return False; bzero((char *)&remap,sizeof(RemapSpec)); + bzero((char *)&tgroup,sizeof(XkbRF_GroupRec)); InitInputLine(&line); while (GetInputLine(file,&line,True)) { - if (CheckLine(&line,&remap,&trule)) { - if ((rule= XkbRF_AddRule(rules))!=NULL) { - *rule= trule; - bzero((char *)&trule,sizeof(XkbRF_RuleRec)); + if (CheckLine(&line,&remap,&trule,&tgroup)) { + if (tgroup.number) { + if ((group= XkbRF_AddGroup(rules))!=NULL) { + *group= tgroup; + bzero((char *)&tgroup,sizeof(XkbRF_GroupRec)); + } + } else { + if ((rule= XkbRF_AddRule(rules))!=NULL) { + *rule= trule; + bzero((char *)&trule,sizeof(XkbRF_RuleRec)); + } } } line.num_line= 0; @@ -976,7 +1275,7 @@ XkbRF_LoadDescriptions(file,rules) InputLine line; XkbRF_VarDescRec tmp; char *tok; -int len,headingtype,extra_ndx; +int len,headingtype,extra_ndx = 0; bzero((char *)&tmp, sizeof(XkbRF_VarDescRec)); headingtype = HEAD_NONE; @@ -1200,6 +1499,7 @@ XkbRF_Free(rules,freeRules) { int i; XkbRF_RulePtr rule; +XkbRF_GroupPtr group; if (!rules) return; @@ -1233,6 +1533,16 @@ XkbRF_RulePtr rule; rules->num_rules= rules->sz_rules= 0; rules->rules= NULL; } + + if (rules->groups) { + for (i=0, group=rules->groups;i<rules->num_groups;i++,group++) { + if (group->name) _XkbFree(group->name); + if (group->words) _XkbFree(group->words); + } + _XkbFree(rules->groups); + rules->num_groups= 0; + rules->groups= NULL; + } if (freeRules) _XkbFree(rules); return; @@ -1246,7 +1556,7 @@ XkbRF_GetNamesProp(Display *dpy,char **rf_rtrn,XkbRF_VarDefsPtr vd_rtrn) #else XkbRF_GetNamesProp(dpy,rf_rtrn,vd_rtrn) Display * dpy; - char ** rf_rtrn; + char ** rf_rtrn; XkbRF_VarDefsPtr vd_rtrn; #endif { @@ -24,6 +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/xkb.c,v 3.18 2002/12/20 20:18:35 paulo Exp $ */ #include <stdio.h> #include "X.h" @@ -231,7 +232,7 @@ ProcXkbSelectEvents(client) client->mapNotifyMask&= ~stuff->affectMap; client->mapNotifyMask|= (stuff->affectMap&stuff->map); } - if (stuff->affectWhich&(~XkbMapNotifyMask)==0) + if ((stuff->affectWhich&(~XkbMapNotifyMask))==0) return client->noClientException; masks = XkbFindClientResource((DevicePtr)dev,client); @@ -1946,7 +1947,7 @@ register XkbServerMapPtr server = xkb->server; register unsigned i; unsigned first,last; - if ((req->present&XkbKeyBehaviorsMask==0)||(req->nKeyBehaviors<1)) { + if (((req->present&XkbKeyBehaviorsMask)==0)||(req->nKeyBehaviors<1)) { req->present&= ~XkbKeyBehaviorsMask; req->nKeyBehaviors= 0; return 1; @@ -2396,21 +2397,21 @@ unsigned first,last; server->behaviors[wire->key].type= wire->type; server->behaviors[wire->key].data= wire->data; if ((wire->type==XkbKB_RadioGroup)&&(((int)wire->data)>maxRG)) - maxRG= wire->data; + maxRG= wire->data + 1; } wire++; } if (maxRG>(int)xkbi->nRadioGroups) { - int sz = (maxRG+1)*sizeof(XkbRadioGroupRec); + int sz = maxRG*sizeof(XkbRadioGroupRec); if (xkbi->radioGroups) - xkbi->radioGroups=(XkbRadioGroupPtr)Xrealloc(xkbi->radioGroups,sz); - else xkbi->radioGroups= (XkbRadioGroupPtr)Xcalloc(sz); + xkbi->radioGroups=(XkbRadioGroupPtr)_XkbRealloc(xkbi->radioGroups,sz); + else xkbi->radioGroups= (XkbRadioGroupPtr)_XkbCalloc(1, sz); if (xkbi->radioGroups) { if (xkbi->nRadioGroups) bzero(&xkbi->radioGroups[xkbi->nRadioGroups], (maxRG-xkbi->nRadioGroups)*sizeof(XkbRadioGroupRec)); - xkbi->nRadioGroups= maxRG+1; + xkbi->nRadioGroups= maxRG; } else xkbi->nRadioGroups= 0; /* should compute members here */ @@ -3323,9 +3324,9 @@ ProcXkbGetNamedIndicator(client) { DeviceIntPtr dev; xkbGetNamedIndicatorReply rep; - register int i; + register int i = 0; XkbSrvLedInfoPtr sli; - XkbIndicatorMapPtr map; + XkbIndicatorMapPtr map = NULL; Bool supported; REQUEST(xkbGetNamedIndicatorReq); @@ -3436,7 +3437,7 @@ ProcXkbSetNamedIndicator(client) DeviceIntPtr dev,kbd; XkbIndicatorMapPtr map; XkbSrvLedInfoPtr sli; - register int led; + register int led = 0; unsigned extDevReason; unsigned statec,namec,mapc; XkbEventCauseRec cause; @@ -4224,7 +4225,7 @@ ProcXkbSetNames(client) names->phys_symbols= *tmp++; if (stuff->which&XkbTypesNameMask) names->types= *tmp++; - if (stuff->which&XkbCompatNameMask) + if (stuff->which&XkbCompatNameMask) names->compat= *tmp++; if ((stuff->which&XkbKeyTypeNamesMask)&&(stuff->nTypes>0)) { register unsigned i; @@ -4310,7 +4311,7 @@ ProcXkbSetNames(client) tmp+= stuff->nRadioGroups; } else if (names->radio_groups) { - Xfree(names->radio_groups); + _XkbFree(names->radio_groups); names->radio_groups= NULL; names->num_rg= 0; } @@ -5597,7 +5598,7 @@ ProcXkbPerClientFlags(client) /* all latin-1 alphanumerics, plus parens, minus, underscore, slash */ /* and wildcards */ static unsigned char componentSpecLegal[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0xa7, 0xff, 0x83, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xa7, 0xff, 0x87, 0xfe, 0xff, 0xff, 0x87, 0xfe, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0x7f, 0xff @@ -5605,7 +5606,7 @@ static unsigned char componentSpecLegal[] = { /* same as above but accepts percent, plus and bar too */ static unsigned char componentExprLegal[] = { - 0x00, 0x00, 0x00, 0x00, 0x20, 0xaf, 0xff, 0x83, + 0x00, 0x00, 0x00, 0x00, 0x20, 0xaf, 0xff, 0x87, 0xfe, 0xff, 0xff, 0x87, 0xfe, 0xff, 0xff, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0x7f, 0xff @@ -5631,7 +5632,7 @@ unsigned char *wire,*str,*tmp,*legal; wire= *pWire; len= (*(unsigned char *)wire++); if (len>0) { - str= (unsigned char *)Xcalloc(len+1); + str= (unsigned char *)_XkbCalloc(1, len+1); if (str) { tmp= str; for (i=0;i<len;i++) { @@ -5642,7 +5643,7 @@ unsigned char *wire,*str,*tmp,*legal; if (tmp!=str) *tmp++= '\0'; else { - Xfree(str); + _XkbFree(str); str= NULL; } } @@ -6018,10 +6019,6 @@ ProcXkbGetKbdByName(client) dev->key->xkbInfo->desc= xkb; finfo.xkb= old_xkb; /* so it'll get freed automatically */ - if (dev->kbdfeed && dev->kbdfeed->xkb_sli) { - XkbFreeSrvLedInfo(dev->kbdfeed->xkb_sli); - dev->kbdfeed->xkb_sli= NULL; - } *xkb->ctrls= *old_xkb->ctrls; for (nG=nTG=0,i=xkb->min_key_code;i<=xkb->max_key_code;i++) { nG= XkbKeyNumGroups(xkb,i); @@ -6038,6 +6035,20 @@ ProcXkbGetKbdByName(client) memcpy(dev->key->modifierMap,xkb->map->modmap,xkb->max_key_code+1); XkbUpdateCoreDescription(dev,True); + if (dev->kbdfeed && dev->kbdfeed->xkb_sli) { + XkbSrvLedInfoPtr old_sli; + XkbSrvLedInfoPtr sli; + old_sli = dev->kbdfeed->xkb_sli; + dev->kbdfeed->xkb_sli = NULL; + sli = XkbAllocSrvLedInfo(dev,dev->kbdfeed,NULL,0); + if (sli) { + sli->explicitState = old_sli->explicitState; + sli->effectiveState = old_sli->effectiveState; + } + dev->kbdfeed->xkb_sli = sli; + XkbFreeSrvLedInfo(old_sli); + } + nkn.deviceID= nkn.oldDeviceID= dev->id; nkn.minKeyCode= finfo.xkb->min_key_code; nkn.maxKeyCode= finfo.xkb->max_key_code; @@ -6054,12 +6065,12 @@ ProcXkbGetKbdByName(client) XkbFreeKeyboard(finfo.xkb,XkbAllComponentsMask,True); finfo.xkb= NULL; } - if (names.keymap) { Xfree(names.keymap); names.keymap= NULL; } - if (names.keycodes) { Xfree(names.keycodes); names.keycodes= NULL; } - if (names.types) { Xfree(names.types); names.types= NULL; } - if (names.compat) { Xfree(names.compat); names.compat= NULL; } - if (names.symbols) { Xfree(names.symbols); names.symbols= NULL; } - if (names.geometry) { Xfree(names.geometry); names.geometry= NULL; } + if (names.keymap) { _XkbFree(names.keymap); names.keymap= NULL; } + if (names.keycodes) { _XkbFree(names.keycodes); names.keycodes= NULL; } + if (names.types) { _XkbFree(names.types); names.types= NULL; } + if (names.compat) { _XkbFree(names.compat); names.compat= NULL; } + if (names.symbols) { _XkbFree(names.symbols); names.symbols= NULL; } + if (names.geometry) { _XkbFree(names.geometry); names.geometry= NULL; } return client->noClientException; } @@ -6914,9 +6925,9 @@ XkbExtensionInit() { ExtensionEntry *extEntry; - if (extEntry = AddExtension(XkbName, XkbNumberEvents, XkbNumberErrors, + if ((extEntry = AddExtension(XkbName, XkbNumberEvents, XkbNumberErrors, ProcXkbDispatch, SProcXkbDispatch, - XkbResetProc, StandardMinorOpcode)) { + XkbResetProc, StandardMinorOpcode))) { XkbReqCode = (unsigned char)extEntry->base; XkbEventBase = (unsigned char)extEntry->eventBase; XkbErrorBase = (unsigned char)extEntry->errorBase; diff --git a/xkb/xkbAccessX.c b/xkb/xkbAccessX.c index 7596d068b..b83f8b626 100644 --- a/xkb/xkbAccessX.c +++ b/xkb/xkbAccessX.c @@ -24,16 +24,20 @@ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ********************************************************/ +/* $XFree86: xc/programs/Xserver/xkb/xkbAccessX.c,v 1.9 2001/08/23 14:33:25 alanh Exp $ */ #include <stdio.h> #include <math.h> +#ifdef __QNX__ +#include <limits.h> +#endif #define NEED_EVENTS 1 #include <X11/X.h> #include <X11/Xproto.h> #include <X11/keysym.h> #include "inputstr.h" #include "XKBsrv.h" -#ifndef WIN32 +#if !defined(WIN32) && !defined(Lynx) #include <sys/time.h> #endif @@ -139,9 +143,6 @@ AccessXKeyboardEvent(keybd,type,keyCode,isRepeat) #endif { xEvent xE; -#ifdef XINPUT -extern int DeviceKeyPress; -#endif xE.u.u.type = type; xE.u.u.detail = keyCode; @@ -582,12 +583,11 @@ KeySym * sym = XkbKeySymsPtr(xkbi->desc,key); */ if (ctrls->enabled_ctrls & XkbSlowKeysMask) { xkbAccessXNotify ev; - /* If key was already pressed, ignore subsequent press events - * from the server's autorepeat + /* If key was already pressed, ignore subsequent press events + * from the server's autorepeat */ if(xkbi->slowKey == key) - return TRUE; - + return TRUE; ev.detail= XkbAXN_SKPress; ev.keycode= key; ev.slowKeysDelay= ctrls->slow_keys_delay; diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c index fd8910841..7f3c47ebc 100644 --- a/xkb/xkbActions.c +++ b/xkb/xkbActions.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/programs/Xserver/xkb/xkbActions.c,v 3.11 2003/02/13 15:36:48 dawes Exp $ */ #include <stdio.h> #include <math.h> @@ -137,7 +138,7 @@ XkbAction * pActs; static XkbAction fake; xkb= xkbi->desc; - if (!XkbKeyHasActions(xkb,key)) { + if (!XkbKeyHasActions(xkb,key) || !XkbKeycodeInRange(xkb,key)) { fake.type = XkbSA_NoAction; return fake; } @@ -244,7 +245,6 @@ _XkbFilterSetState(xkbi,filter,keycode,pAction) XkbAction * pAction; #endif { - if (filter->keycode==0) { /* initial press */ filter->keycode = keycode; filter->active = 1; @@ -620,14 +620,12 @@ Bool accel; AccessXCancelRepeatKey(xkbi,keycode); xkbi->mouseKeysAccel= accel&& (xkbi->desc->ctrls->enabled_ctrls&XkbMouseKeysAccelMask); - if (xkbi->mouseKeysAccel) { - xkbi->mouseKeysFlags= pAction->ptr.flags; - xkbi->mouseKeysDX= XkbPtrActionX(&pAction->ptr); - xkbi->mouseKeysDY= XkbPtrActionY(&pAction->ptr); - xkbi->mouseKeyTimer= TimerSet(xkbi->mouseKeyTimer, 0, + xkbi->mouseKeysFlags= pAction->ptr.flags; + xkbi->mouseKeysDX= XkbPtrActionX(&pAction->ptr); + xkbi->mouseKeysDY= XkbPtrActionY(&pAction->ptr); + xkbi->mouseKeyTimer= TimerSet(xkbi->mouseKeyTimer, 0, xkbi->desc->ctrls->mk_delay, _XkbPtrAccelExpire,(pointer)xkbi); - } } else if (filter->keycode==keycode) { filter->active = 0; @@ -844,7 +842,7 @@ XkbEventCauseRec cause; filter->keycode= 0; filter->active= 0; } - return 0; + return 1; } static int @@ -923,12 +921,12 @@ _XkbFilterRedirectKey(xkbi,filter,keycode,pAction) { unsigned realMods; xEvent ev; -int x,y,kc; +int x,y; XkbStateRec old; -unsigned mods,mask,oldCoreState,oldCorePrevState; +unsigned mods,mask,oldCoreState = 0,oldCorePrevState = 0; if ((filter->keycode!=0)&&(filter->keycode!=keycode)) - return 0; + return 1; GetSpritePosition(&x,&y); ev.u.keyButtonPointer.time = GetTimeInMillis(); @@ -982,8 +980,6 @@ unsigned mods,mask,oldCoreState,oldCorePrevState; xkbi->device->key->prev_state= oldCorePrevState; xkbi->state= old; } - - return 0; } else if (filter->keycode==keycode) { @@ -1018,10 +1014,72 @@ unsigned mods,mask,oldCoreState,oldCorePrevState; filter->keycode= 0; filter->active= 0; - return 0; } - return 0; + return 1; +} + +static int +#if NeedFunctionPrototypes +_XkbFilterSwitchScreen( XkbSrvInfoPtr xkbi, + XkbFilterPtr filter, + unsigned keycode, + XkbAction * pAction) +#else +_XkbFilterSwitchScreen(xkbi,filter,keycode,pAction) + XkbSrvInfoPtr xkbi; + XkbFilterPtr filter; + unsigned keycode; + XkbAction * pAction; +#endif +{ + if (filter->keycode==0) { /* initial press */ + DeviceIntPtr dev = xkbi->device; + filter->keycode = keycode; + filter->active = 1; + filter->filterOthers = 0; + filter->filter = _XkbFilterSwitchScreen; + AccessXCancelRepeatKey(xkbi, keycode); + XkbDDXSwitchScreen(dev,keycode,pAction); + return 0; + } + else if (filter->keycode==keycode) { + filter->active= 0; + return 0; + } + return 1; +} + +#ifdef XFree86Server +static int +#if NeedFunctionPrototypes +_XkbFilterXF86Private( XkbSrvInfoPtr xkbi, + XkbFilterPtr filter, + unsigned keycode, + XkbAction * pAction) +#else +_XkbFilterXF86Private(xkbi,filter,keycode,pAction) + XkbSrvInfoPtr xkbi; + XkbFilterPtr filter; + unsigned keycode; + XkbAction * pAction; +#endif +{ + if (filter->keycode==0) { /* initial press */ + DeviceIntPtr dev = xkbi->device; + filter->keycode = keycode; + filter->active = 1; + filter->filterOthers = 0; + filter->filter = _XkbFilterXF86Private; + XkbDDXPrivate(dev,keycode,pAction); + return 0; + } + else if (filter->keycode==keycode) { + filter->active= 0; + return 0; + } + return 1; } +#endif #ifdef XINPUT @@ -1251,7 +1309,8 @@ Bool xiEvent; sendEvent= XkbDDXTerminateServer(dev,key,&act); break; case XkbSA_SwitchScreen: - sendEvent= XkbDDXSwitchScreen(dev,key,&act); + filter = _XkbNextFreeFilter(); + sendEvent=_XkbFilterSwitchScreen(xkbi,filter,key,&act); break; case XkbSA_SetControls: case XkbSA_LockControls: @@ -1273,6 +1332,12 @@ Bool xiEvent; sendEvent= _XkbFilterDeviceBtn(xkbi,filter,key,&act); break; #endif +#ifdef XFree86Server + case XkbSA_XFree86Private: + filter = _XkbNextFreeFilter(); + sendEvent= _XkbFilterXF86Private(xkbi,filter,key,&act); + break; +#endif } } } @@ -1307,7 +1372,7 @@ Bool xiEvent; } if (sendEvent) { -#if XINPUT +#ifdef XINPUT if (xiEvent) ProcessOtherEvent(xE,dev,count); else @@ -1320,6 +1385,9 @@ Bool xiEvent; } else CoreProcessPointerEvent(xE,dev,count); } + else if (keyEvent) + FixKeyState(xE,dev); + xkbi->prev_state= oldState; XkbComputeDerivedState(xkbi); keyc->prev_state= keyc->state; diff --git a/xkb/xkbDflts.h b/xkb/xkbDflts.h index a79202065..417478ef4 100644 --- a/xkb/xkbDflts.h +++ b/xkb/xkbDflts.h @@ -1,4 +1,5 @@ /* $Xorg: xkbDflts.h,v 1.3 2000/08/17 19:53:47 cpqbld Exp $ */ +/* $XFree86: xc/programs/Xserver/xkb/xkbDflts.h,v 1.2 2001/10/28 03:34:20 tsi Exp $ */ /* This file generated automatically by xkbcomp */ /* DO NOT EDIT */ #ifndef DEFAULT_H @@ -176,279 +177,279 @@ static XkbSymInterpretRec dfltSI[69]= { { XK_ISO_Level2_Latch, 0x0000, XkbSI_LevelOneOnly|XkbSI_Exactly, ShiftMask, 255, - { XkbSA_LatchMods, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00 } }, + { XkbSA_LatchMods, { 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00 } } }, { XK_Eisu_Shift, 0x0000, XkbSI_Exactly, LockMask, 255, - { XkbSA_NoAction, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }, + { XkbSA_NoAction, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } }, { XK_Eisu_toggle, 0x0000, XkbSI_Exactly, LockMask, 255, - { XkbSA_NoAction, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }, + { XkbSA_NoAction, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } }, { XK_Kana_Shift, 0x0000, XkbSI_Exactly, LockMask, 255, - { XkbSA_NoAction, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }, + { XkbSA_NoAction, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } }, { XK_Kana_Lock, 0x0000, XkbSI_Exactly, LockMask, 255, - { XkbSA_NoAction, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }, + { XkbSA_NoAction, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } }, { XK_Shift_Lock, 0x0000, XkbSI_AnyOf, ShiftMask|LockMask, 255, - { XkbSA_LockMods, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00 } }, + { XkbSA_LockMods, { 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00 } } }, { XK_Num_Lock, 0x0000, XkbSI_AnyOf, 0xff, 0, - { XkbSA_LockMods, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00 } }, + { XkbSA_LockMods, { 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00 } } }, { XK_Alt_L, 0x0000, XkbSI_AnyOf, 0xff, 1, - { XkbSA_SetMods, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }, + { XkbSA_SetMods, { 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } }, { XK_Alt_R, 0x0000, XkbSI_AnyOf, 0xff, 1, - { XkbSA_SetMods, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }, + { XkbSA_SetMods, { 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } }, { XK_Scroll_Lock, 0x0000, XkbSI_AnyOf, 0xff, 4, - { XkbSA_LockMods, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }, + { XkbSA_LockMods, { 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } }, { XK_ISO_Lock, 0x0000, XkbSI_AnyOf, 0xff, 255, - { XkbSA_ISOLock, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }, + { XkbSA_ISOLock, { 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } }, { XK_ISO_Level3_Shift, 0x0000, XkbSI_LevelOneOnly|XkbSI_AnyOf, 0xff, 2, - { XkbSA_SetMods, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00 } }, + { XkbSA_SetMods, { 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00 } } }, { XK_ISO_Level3_Latch, 0x0000, XkbSI_LevelOneOnly|XkbSI_AnyOf, 0xff, 2, - { XkbSA_LatchMods, 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00 } }, + { XkbSA_LatchMods, { 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00 } } }, { XK_Mode_switch, 0x0000, XkbSI_LevelOneOnly|XkbSI_AnyOfOrNone, 0xff, 3, - { XkbSA_SetGroup, 0x05, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 } }, + { XkbSA_SetGroup, { 0x05, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 } } }, { XK_KP_1, 0x0001, XkbSI_AnyOfOrNone, 0xff, 255, - { XkbSA_MovePtr, 0x00, 0xff, 0xff, 0x00, 0x01, 0x00, 0x00 } }, + { XkbSA_MovePtr, { 0x00, 0xff, 0xff, 0x00, 0x01, 0x00, 0x00 } } }, { XK_KP_End, 0x0001, XkbSI_AnyOfOrNone, 0xff, 255, - { XkbSA_MovePtr, 0x00, 0xff, 0xff, 0x00, 0x01, 0x00, 0x00 } }, + { XkbSA_MovePtr, { 0x00, 0xff, 0xff, 0x00, 0x01, 0x00, 0x00 } } }, { XK_KP_2, 0x0001, XkbSI_AnyOfOrNone, 0xff, 255, - { XkbSA_MovePtr, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00 } }, + { XkbSA_MovePtr, { 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00 } } }, { XK_KP_Down, 0x0001, XkbSI_AnyOfOrNone, 0xff, 255, - { XkbSA_MovePtr, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00 } }, + { XkbSA_MovePtr, { 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00 } } }, { XK_KP_3, 0x0001, XkbSI_AnyOfOrNone, 0xff, 255, - { XkbSA_MovePtr, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00 } }, + { XkbSA_MovePtr, { 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00 } } }, { XK_KP_Next, 0x0001, XkbSI_AnyOfOrNone, 0xff, 255, - { XkbSA_MovePtr, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00 } }, + { XkbSA_MovePtr, { 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00 } } }, { XK_KP_4, 0x0001, XkbSI_AnyOfOrNone, 0xff, 255, - { XkbSA_MovePtr, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 } }, + { XkbSA_MovePtr, { 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 } } }, { XK_KP_Left, 0x0001, XkbSI_AnyOfOrNone, 0xff, 255, - { XkbSA_MovePtr, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 } }, + { XkbSA_MovePtr, { 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 } } }, { XK_KP_6, 0x0001, XkbSI_AnyOfOrNone, 0xff, 255, - { XkbSA_MovePtr, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 } }, + { XkbSA_MovePtr, { 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 } } }, { XK_KP_Right, 0x0001, XkbSI_AnyOfOrNone, 0xff, 255, - { XkbSA_MovePtr, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 } }, + { XkbSA_MovePtr, { 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 } } }, { XK_KP_7, 0x0001, XkbSI_AnyOfOrNone, 0xff, 255, - { XkbSA_MovePtr, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00 } }, + { XkbSA_MovePtr, { 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00 } } }, { XK_KP_Home, 0x0001, XkbSI_AnyOfOrNone, 0xff, 255, - { XkbSA_MovePtr, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00 } }, + { XkbSA_MovePtr, { 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00 } } }, { XK_KP_8, 0x0001, XkbSI_AnyOfOrNone, 0xff, 255, - { XkbSA_MovePtr, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00 } }, + { XkbSA_MovePtr, { 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00 } } }, { XK_KP_Up, 0x0001, XkbSI_AnyOfOrNone, 0xff, 255, - { XkbSA_MovePtr, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00 } }, + { XkbSA_MovePtr, { 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00 } } }, { XK_KP_9, 0x0001, XkbSI_AnyOfOrNone, 0xff, 255, - { XkbSA_MovePtr, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00 } }, + { XkbSA_MovePtr, { 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00 } } }, { XK_KP_Prior, 0x0001, XkbSI_AnyOfOrNone, 0xff, 255, - { XkbSA_MovePtr, 0x00, 0x00, 0x01, 0xff, 0xff, 0x00, 0x00 } }, + { XkbSA_MovePtr, { 0x00, 0x00, 0x01, 0xff, 0xff, 0x00, 0x00 } } }, { XK_KP_5, 0x0001, XkbSI_AnyOfOrNone, 0xff, 255, - { XkbSA_PtrBtn, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }, + { XkbSA_PtrBtn, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } }, { XK_KP_Begin, 0x0001, XkbSI_AnyOfOrNone, 0xff, 255, - { XkbSA_PtrBtn, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }, + { XkbSA_PtrBtn, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } }, { XK_KP_F1, 0x0001, XkbSI_AnyOfOrNone, 0xff, 255, - { XkbSA_SetPtrDflt, 0x04, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00 } }, + { XkbSA_SetPtrDflt, { 0x04, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00 } } }, { XK_KP_Divide, 0x0001, XkbSI_AnyOfOrNone, 0xff, 255, - { XkbSA_SetPtrDflt, 0x04, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00 } }, + { XkbSA_SetPtrDflt, { 0x04, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00 } } }, { XK_KP_F2, 0x0001, XkbSI_AnyOfOrNone, 0xff, 255, - { XkbSA_SetPtrDflt, 0x04, 0x01, 0x02, 0x00, 0x00, 0x00, 0x00 } }, + { XkbSA_SetPtrDflt, { 0x04, 0x01, 0x02, 0x00, 0x00, 0x00, 0x00 } } }, { XK_KP_Multiply, 0x0001, XkbSI_AnyOfOrNone, 0xff, 255, - { XkbSA_SetPtrDflt, 0x04, 0x01, 0x02, 0x00, 0x00, 0x00, 0x00 } }, + { XkbSA_SetPtrDflt, { 0x04, 0x01, 0x02, 0x00, 0x00, 0x00, 0x00 } } }, { XK_KP_F3, 0x0001, XkbSI_AnyOfOrNone, 0xff, 255, - { XkbSA_SetPtrDflt, 0x04, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00 } }, + { XkbSA_SetPtrDflt, { 0x04, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00 } } }, { XK_KP_Subtract, 0x0001, XkbSI_AnyOfOrNone, 0xff, 255, - { XkbSA_SetPtrDflt, 0x04, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00 } }, + { XkbSA_SetPtrDflt, { 0x04, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00 } } }, { XK_KP_Separator, 0x0001, XkbSI_AnyOfOrNone, 0xff, 255, - { XkbSA_PtrBtn, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00 } }, + { XkbSA_PtrBtn, { 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00 } } }, { XK_KP_Add, 0x0001, XkbSI_AnyOfOrNone, 0xff, 255, - { XkbSA_PtrBtn, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00 } }, + { XkbSA_PtrBtn, { 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00 } } }, { XK_KP_0, 0x0001, XkbSI_AnyOfOrNone, 0xff, 255, - { XkbSA_LockPtrBtn, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }, + { XkbSA_LockPtrBtn, { 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } }, { XK_KP_Insert, 0x0001, XkbSI_AnyOfOrNone, 0xff, 255, - { XkbSA_LockPtrBtn, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }, + { XkbSA_LockPtrBtn, { 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } }, { XK_KP_Decimal, 0x0001, XkbSI_AnyOfOrNone, 0xff, 255, - { XkbSA_LockPtrBtn, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }, + { XkbSA_LockPtrBtn, { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } }, { XK_KP_Delete, 0x0001, XkbSI_AnyOfOrNone, 0xff, 255, - { XkbSA_LockPtrBtn, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }, + { XkbSA_LockPtrBtn, { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } }, { XK_Pointer_Button_Dflt, 0x0000, XkbSI_AnyOfOrNone, 0xff, 255, - { XkbSA_PtrBtn, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }, + { XkbSA_PtrBtn, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } }, { XK_Pointer_Button1, 0x0000, XkbSI_AnyOfOrNone, 0xff, 255, - { XkbSA_PtrBtn, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 } }, + { XkbSA_PtrBtn, { 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 } } }, { XK_Pointer_Button2, 0x0000, XkbSI_AnyOfOrNone, 0xff, 255, - { XkbSA_PtrBtn, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00 } }, + { XkbSA_PtrBtn, { 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00 } } }, { XK_Pointer_Button3, 0x0000, XkbSI_AnyOfOrNone, 0xff, 255, - { XkbSA_PtrBtn, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00 } }, + { XkbSA_PtrBtn, { 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00 } } }, { XK_Pointer_DblClick_Dflt, 0x0000, XkbSI_AnyOfOrNone, 0xff, 255, - { XkbSA_PtrBtn, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00 } }, + { XkbSA_PtrBtn, { 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00 } } }, { XK_Pointer_DblClick1, 0x0000, XkbSI_AnyOfOrNone, 0xff, 255, - { XkbSA_PtrBtn, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00 } }, + { XkbSA_PtrBtn, { 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00 } } }, { XK_Pointer_DblClick2, 0x0000, XkbSI_AnyOfOrNone, 0xff, 255, - { XkbSA_PtrBtn, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00 } }, + { XkbSA_PtrBtn, { 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00 } } }, { XK_Pointer_DblClick3, 0x0000, XkbSI_AnyOfOrNone, 0xff, 255, - { XkbSA_PtrBtn, 0x00, 0x02, 0x03, 0x00, 0x00, 0x00, 0x00 } }, + { XkbSA_PtrBtn, { 0x00, 0x02, 0x03, 0x00, 0x00, 0x00, 0x00 } } }, { XK_Pointer_Drag_Dflt, 0x0000, XkbSI_AnyOfOrNone, 0xff, 255, - { XkbSA_LockPtrBtn, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }, + { XkbSA_LockPtrBtn, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } }, { XK_Pointer_Drag1, 0x0000, XkbSI_AnyOfOrNone, 0xff, 255, - { XkbSA_LockPtrBtn, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 } }, + { XkbSA_LockPtrBtn, { 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 } } }, { XK_Pointer_Drag2, 0x0000, XkbSI_AnyOfOrNone, 0xff, 255, - { XkbSA_LockPtrBtn, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00 } }, + { XkbSA_LockPtrBtn, { 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00 } } }, { XK_Pointer_Drag3, 0x0000, XkbSI_AnyOfOrNone, 0xff, 255, - { XkbSA_LockPtrBtn, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00 } }, + { XkbSA_LockPtrBtn, { 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00 } } }, { XK_Pointer_EnableKeys, 0x0000, XkbSI_AnyOfOrNone, 0xff, 255, - { XkbSA_LockControls, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00 } }, + { XkbSA_LockControls, { 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00 } } }, { XK_Pointer_Accelerate, 0x0000, XkbSI_AnyOfOrNone, 0xff, 255, - { XkbSA_LockControls, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00 } }, + { XkbSA_LockControls, { 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00 } } }, { XK_Pointer_DfltBtnNext, 0x0000, XkbSI_AnyOfOrNone, 0xff, 255, - { XkbSA_SetPtrDflt, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00 } }, + { XkbSA_SetPtrDflt, { 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00 } } }, { XK_Pointer_DfltBtnPrev, 0x0000, XkbSI_AnyOfOrNone, 0xff, 255, - { XkbSA_SetPtrDflt, 0x00, 0x01, 0xff, 0x00, 0x00, 0x00, 0x00 } }, + { XkbSA_SetPtrDflt, { 0x00, 0x01, 0xff, 0x00, 0x00, 0x00, 0x00 } } }, { XK_AccessX_Enable, 0x0000, XkbSI_AnyOfOrNone, 0xff, 255, - { XkbSA_LockControls, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00 } }, + { XkbSA_LockControls, { 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00 } } }, { XK_Terminate_Server, 0x0000, XkbSI_AnyOfOrNone, 0xff, 255, - { XkbSA_Terminate, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }, + { XkbSA_Terminate, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } }, { XK_ISO_Group_Latch, 0x0000, XkbSI_LevelOneOnly|XkbSI_AnyOfOrNone, 0xff, 3, - { XkbSA_LatchGroup, 0x04, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 } }, + { XkbSA_LatchGroup, { 0x04, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 } } }, { XK_ISO_Next_Group, 0x0000, XkbSI_LevelOneOnly|XkbSI_AnyOfOrNone, 0xff, 3, - { XkbSA_LockGroup, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 } }, + { XkbSA_LockGroup, { 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 } } }, { XK_ISO_Prev_Group, 0x0000, XkbSI_LevelOneOnly|XkbSI_AnyOfOrNone, 0xff, 3, - { XkbSA_LockGroup, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00 } }, + { XkbSA_LockGroup, { 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00 } } }, { XK_ISO_First_Group, 0x0000, XkbSI_AnyOfOrNone, 0xff, 255, - { XkbSA_LockGroup, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }, + { XkbSA_LockGroup, { 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } }, { XK_ISO_Last_Group, 0x0000, XkbSI_AnyOfOrNone, 0xff, 255, - { XkbSA_LockGroup, 0x04, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 } }, + { XkbSA_LockGroup, { 0x04, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 } } }, { NoSymbol, 0x0000, XkbSI_Exactly, LockMask, 255, - { XkbSA_LockMods, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00 } }, + { XkbSA_LockMods, { 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00 } } }, { NoSymbol, 0x0000, XkbSI_AnyOf, 0xff, 255, - { XkbSA_SetMods, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } + { XkbSA_SetMods, { 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } } }; #define num_dfltSI (sizeof(dfltSI)/sizeof(XkbSymInterpretRec)) @@ -466,38 +467,38 @@ static XkbCompatMapRec compatMap= { static XkbIndicatorRec indicators= { 0x0, { - { 0x80, 0, 0x00, XkbIM_UseEffective, LockMask, LockMask, 0, 0 }, - { 0x80, 0, 0x00, XkbIM_UseEffective, 0, 0, vmod_NumLockMask, 0 }, - { 0x80, 0, 0x00, XkbIM_UseLocked, ShiftMask, ShiftMask, 0, 0 }, - { 0x80, 0, 0x00, 0, 0, 0, 0, XkbMouseKeysMask }, - { 0x80, 0, 0x00, XkbIM_UseLocked, 0, 0, vmod_ScrollLockMask, 0 }, - { 0x80, XkbIM_UseEffective, 0xfe, 0, 0, 0, 0, 0 }, - { 0x00, 0, 0x00, 0, 0, 0, 0, 0 }, - { 0x00, 0, 0x00, 0, 0, 0, 0, 0 }, - { 0x00, 0, 0x00, 0, 0, 0, 0, 0 }, - { 0x00, 0, 0x00, 0, 0, 0, 0, 0 }, - { 0x00, 0, 0x00, 0, 0, 0, 0, 0 }, - { 0x00, 0, 0x00, 0, 0, 0, 0, 0 }, - { 0x00, 0, 0x00, 0, 0, 0, 0, 0 }, - { 0x00, 0, 0x00, 0, 0, 0, 0, 0 }, - { 0x00, 0, 0x00, 0, 0, 0, 0, 0 }, - { 0x00, 0, 0x00, 0, 0, 0, 0, 0 }, - { 0x00, 0, 0x00, 0, 0, 0, 0, 0 }, - { 0x00, 0, 0x00, 0, 0, 0, 0, 0 }, - { 0x00, 0, 0x00, 0, 0, 0, 0, 0 }, - { 0x00, 0, 0x00, 0, 0, 0, 0, 0 }, - { 0x00, 0, 0x00, 0, 0, 0, 0, 0 }, - { 0x00, 0, 0x00, 0, 0, 0, 0, 0 }, - { 0x00, 0, 0x00, 0, 0, 0, 0, 0 }, - { 0x00, 0, 0x00, 0, 0, 0, 0, 0 }, - { 0x00, 0, 0x00, 0, 0, 0, 0, 0 }, - { 0x00, 0, 0x00, 0, 0, 0, 0, 0 }, - { 0x00, 0, 0x00, 0, 0, 0, 0, 0 }, - { 0x00, 0, 0x00, 0, 0, 0, 0, 0 }, - { 0x00, 0, 0x00, 0, 0, 0, 0, 0 }, - { 0x00, 0, 0x00, 0, 0, 0, 0, 0 }, - { 0x00, 0, 0x00, 0, 0, 0, 0, 0 }, - { 0x00, 0, 0x00, 0, 0, 0, 0, 0 } + { 0x80, 0, 0x00, XkbIM_UseEffective, { LockMask, LockMask, 0 }, 0 }, + { 0x80, 0, 0x00, XkbIM_UseEffective, { 0, 0, vmod_NumLockMask }, 0 }, + { 0x80, 0, 0x00, XkbIM_UseLocked, { ShiftMask, ShiftMask, 0 }, 0 }, + { 0x80, 0, 0x00, 0, { 0, 0, 0 }, XkbMouseKeysMask }, + { 0x80, 0, 0x00, XkbIM_UseLocked, { 0, 0, vmod_ScrollLockMask }, 0 }, + { 0x80, XkbIM_UseEffective, 0xfe, 0, { 0, 0, 0 }, 0 }, + { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 }, + { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 }, + { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 }, + { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 }, + { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 }, + { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 }, + { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 }, + { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 }, + { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 }, + { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 }, + { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 }, + { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 }, + { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 }, + { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 }, + { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 }, + { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 }, + { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 }, + { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 }, + { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 }, + { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 }, + { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 }, + { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 }, + { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 }, + { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 }, + { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 }, + { 0x00, 0, 0x00, 0, { 0, 0, 0 }, 0 } } }; static void diff --git a/xkb/xkbEvents.c b/xkb/xkbEvents.c index 5a0f1d54b..291674fcf 100644 --- a/xkb/xkbEvents.c +++ b/xkb/xkbEvents.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/programs/Xserver/xkb/xkbEvents.c,v 3.10 2001/10/28 03:34:20 tsi Exp $ */ #include <stdio.h> #define NEED_EVENTS 1 @@ -35,8 +36,6 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "windowstr.h" #include "XKBsrv.h" -extern int (*InitialVector[3])(); - /***====================================================================***/ void @@ -51,7 +50,6 @@ XkbSendNewKeyboardNotify(kbd,pNKN) register int i; Time time; CARD16 changed; -XkbChangesRec changes; pNKN->type = XkbEventCode + XkbEventBase; pNKN->xkbType = XkbNewKeyboardNotify; @@ -181,7 +179,7 @@ XkbSendMapNotify(kbd,pMN) { int i; XkbSrvInfoPtr xkbi; -unsigned time,initialized; +unsigned time = 0,initialized; CARD16 changed; xkbi = kbd->key->xkbInfo; @@ -260,6 +258,10 @@ CARD32 changedControls; changedControls|= XkbMouseKeysAccelMask; if (old->ax_options!=new->ax_options) changedControls|= XkbAccessXKeysMask; + if ((old->ax_options^new->ax_options) & XkbAX_SKOptionsMask) + changedControls|= XkbStickyKeysMask; + if ((old->ax_options^new->ax_options) & XkbAX_FBOptionsMask) + changedControls|= XkbAccessXFeedbackMask; if ((old->ax_timeout!=new->ax_timeout)|| (old->axt_ctrls_mask!=new->axt_ctrls_mask)|| (old->axt_ctrls_values!=new->axt_ctrls_values)|| @@ -308,10 +310,10 @@ XkbSendControlsNotify(kbd,pCN) #endif { int initialized; -CARD32 changedControls,enabledControls,enabledChanges; +CARD32 changedControls, enabledControls, enabledChanges = 0; XkbSrvInfoPtr xkbi; XkbInterestPtr interest; -Time time; +Time time = 0; interest = kbd->xkb_interest; if (!interest) @@ -367,7 +369,7 @@ XkbSendIndicatorNotify(kbd,xkbType,pEv) { int initialized; XkbInterestPtr interest; -Time time; +Time time = 0; CARD32 state,changed; interest = kbd->xkb_interest; @@ -441,8 +443,8 @@ XkbSrvInfoPtr xkbi; XkbInterestPtr interest; CARD8 id; CARD16 pitch,duration; -Time time; -XID winID; +Time time = 0; +XID winID = 0; xkbi = kbd->key->xkbInfo; @@ -519,7 +521,7 @@ XkbSendAccessXNotify(kbd,pEv) { int initialized; XkbInterestPtr interest; -Time time; +Time time = 0; CARD16 sk_delay,db_delay; interest = kbd->xkb_interest; @@ -570,7 +572,7 @@ XkbSendNamesNotify(kbd,pEv) { int initialized; XkbInterestPtr interest; -Time time; +Time time = 0; CARD16 changed,changedVirtualMods; CARD32 changedIndicators; @@ -625,8 +627,8 @@ XkbSendCompatMapNotify(kbd,pEv) { int initialized; XkbInterestPtr interest; -Time time; -CARD16 firstSI,nSI,nTotalSI; +Time time = 0; +CARD16 firstSI = 0, nSI = 0, nTotalSI = 0; interest = kbd->xkb_interest; if (!interest) @@ -680,7 +682,7 @@ XkbSendActionMessage(kbd,pEv) int initialized; XkbSrvInfoPtr xkbi; XkbInterestPtr interest; -Time time; +Time time = 0; xkbi = kbd->key->xkbInfo; interest = kbd->xkb_interest; @@ -731,9 +733,9 @@ XkbSendExtensionDeviceNotify(dev,client,pEv) { int initialized; XkbInterestPtr interest; -Time time; -CARD32 defined,state; -CARD16 reason,supported; +Time time = 0; +CARD32 defined, state; +CARD16 reason, supported = 0; interest = dev->xkb_interest; if (!interest) @@ -894,7 +896,7 @@ XkbFilterEvents(pClient,nEvents,xE) xEvent *xE; #endif { -int i; +int i, button_mask; DeviceIntPtr pXDev = (DeviceIntPtr)LookupKeyboardDevice(); XkbSrvInfoPtr xkbi; @@ -920,7 +922,7 @@ XkbSrvInfoPtr xkbi; (_XkbIsReleaseEvent(xE[0].u.u.type)) ) { return False; } - if ((pXDev->grab != NullGrab) && + if ((pXDev->grab != NullGrab) && pXDev->fromPassiveGrab && ((xE[0].u.u.type==KeyPress)||(xE[0].u.u.type==KeyRelease))) { register unsigned state,flags; @@ -945,6 +947,19 @@ XkbSrvInfoPtr xkbi; state= xkbi->state.compat_lookup_mods; xE[0].u.keyButtonPointer.state= state; } + button_mask = 1 << xE[0].u.u.detail; + if (xE[0].u.u.type == ButtonPress && + ((xE[0].u.keyButtonPointer.state >> 7) & button_mask) == button_mask && + (xkbi->lockedPtrButtons & button_mask) == button_mask) { +#ifdef DEBUG + /* If the MouseKeys is pressed, and the "real" mouse is also pressed + * when the mouse is released, the server does not behave properly. + * Faking a release of the button here solves the problem. + */ + ErrorF("Faking release of button %d\n", xE[0].u.u.detail); +#endif + XkbDDXFakePointerButton(ButtonRelease, xE[0].u.u.detail); + } } else { register CARD8 type; @@ -979,6 +994,15 @@ XkbSrvInfoPtr xkbi; xE->u.enterLeave.state&= 0x1F00; xE->u.enterLeave.state|= xkbi->state.compat_grab_mods; } + button_mask = 1 << xE[i].u.u.detail; + if (type == ButtonPress && + ((xE[i].u.keyButtonPointer.state >> 7) & button_mask) == button_mask && + (xkbi->lockedPtrButtons & button_mask) == button_mask) { +#ifdef DEBUG + ErrorF("Faking release of button %d\n", xE[i].u.u.detail); +#endif + XkbDDXFakePointerButton(ButtonRelease, xE[i].u.u.detail); + } } } return True; @@ -1074,7 +1098,7 @@ Bool found; dev->xkb_interest = interest->next; autoCtrls= interest->autoCtrls; autoValues= interest->autoCtrlValues; - xfree(interest); + _XkbFree(interest); found= True; } while ((!found)&&(interest->next)) { @@ -1083,7 +1107,7 @@ Bool found; interest->next = victim->next; autoCtrls= victim->autoCtrls; autoValues= victim->autoCtrlValues; - xfree(victim); + _XkbFree(victim); found= True; } interest = interest->next; @@ -1113,7 +1137,7 @@ DeviceIntPtr dev = (DeviceIntPtr)inDev; XkbInterestPtr interest; Bool found; unsigned long autoCtrls,autoValues; -ClientPtr client; +ClientPtr client = NULL; found= False; autoCtrls= autoValues= 0; @@ -1124,7 +1148,7 @@ ClientPtr client; autoCtrls= interest->autoCtrls; autoValues= interest->autoCtrlValues; client= interest->client; - xfree(interest); + _XkbFree(interest); found= True; } while ((!found)&&(interest->next)) { @@ -1134,7 +1158,7 @@ ClientPtr client; autoCtrls= victim->autoCtrls; autoValues= victim->autoCtrlValues; client= victim->client; - xfree(victim); + _XkbFree(victim); found= True; } interest = interest->next; @@ -1149,6 +1173,3 @@ ClientPtr client; } return found; } - - - diff --git a/xkb/xkbInit.c b/xkb/xkbInit.c index 3ca52ebc5..5074b8bfb 100644 --- a/xkb/xkbInit.c +++ b/xkb/xkbInit.c @@ -1,6 +1,3 @@ -/* - * @(#)$RCSfile$ $Revision$ (DEC) $Date$ - */ /* $Xorg: xkbInit.c,v 1.3 2000/08/17 19:53:47 cpqbld Exp $ */ /************************************************************ Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc. @@ -27,10 +24,12 @@ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ********************************************************/ +/* $XFree86: xc/programs/Xserver/xkb/xkbInit.c,v 3.26.2.1 2003/03/17 23:53:14 paulo Exp $ */ #include <stdio.h> #include <stdlib.h> #include <ctype.h> +#include <unistd.h> #include <math.h> #define NEED_EVENTS 1 #include <X11/X.h> @@ -39,6 +38,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include <X11/Xatom.h> #include "misc.h" #include "inputstr.h" +#include "opaque.h" #include "property.h" #define XKBSRV_NEED_FILE_FUNCS #include "XKBsrv.h" @@ -56,7 +56,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #define PHYS_LEDS 0x7f #define LED_COMPOSE 8 #else -#if defined(ultrix) || defined(__osf__) || defined(__alpha) +#if defined(ultrix) || defined(__osf__) || defined(__alpha) || defined(__alpha__) #define LED_COMPOSE 2 #define LED_CAPS 3 #define LED_SCROLL 4 @@ -169,7 +169,6 @@ XkbWriteRulesProp(client, closure) #endif { int len,out; -extern WindowPtr * WindowTable; Atom name; char * pval; @@ -305,6 +304,9 @@ XkbSetRulesDflts(rulesFile,model,layout,variant,options) #include "xkbDflts.h" +/* A dummy to keep the compiler quiet */ +pointer xkbBogus = &indicators; + static Bool #if NeedFunctionPrototypes XkbInitKeyTypes(XkbDescPtr xkb,SrvXkmInfo *file) @@ -441,7 +443,7 @@ Atom unknown; } #ifdef DEBUG_RADIO_GROUPS if (names->num_rg<1) { - names->radio_groups= (Atom *)Xcalloc(RG_COUNT*sizeof(Atom)); + names->radio_groups= (Atom *)_XkbCalloc(RG_COUNT, sizeof(Atom)); if (names->radio_groups) { names->num_rg = RG_COUNT; names->radio_groups[RG_BOGUS_FUNCTION_GROUP]= CREATE_ATOM("BOGUS"); @@ -483,6 +485,13 @@ XkbSrvLedInfoPtr sli; 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 */ } sli= XkbFindSrvLedInfo(xkbi->device,XkbDfltXIClass,XkbDfltXIId,0); if (sli) @@ -652,6 +661,10 @@ XkbEventCauseRec cause; return; } +#if MAP_LENGTH > XkbMaxKeyCount +#undef XkbMaxKeyCount +#define XkbMaxKeyCount MAP_LENGTH +#endif Bool #if NeedFunctionPrototypes @@ -675,7 +688,7 @@ XkbFileInfo finfo; KeySymsRec tmpSyms,*pSyms; CARD8 tmpMods[XkbMaxLegalKeyCode+1],*pMods; char name[PATH_MAX],*rules; -Bool ok; +Bool ok=False; XPointer config; XkbComponentNamesRec cfgNames; XkbRF_VarDefsRec defs; @@ -689,29 +702,94 @@ XkbRF_VarDefsRec defs; rules= XkbGetRulesDflts(&defs); config= XkbDDXPreloadConfig(&rules,&defs,&cfgNames,dev); + /* + * The strings are duplicated because it is not guaranteed that + * they are allocated, or that they are allocated for every server + * generation. Eventually they will be freed at the end of this + * function. + */ + if (names->keymap) names->keymap = _XkbDupString(names->keymap); + if (names->keycodes) names->keycodes = _XkbDupString(names->keycodes); + if (names->types) names->types = _XkbDupString(names->types); + if (names->compat) names->compat = _XkbDupString(names->compat); + if (names->geometry) names->geometry = _XkbDupString(names->geometry); + if (names->symbols) names->symbols = _XkbDupString(names->symbols); + if (defs.model && defs.layout && rules) { XkbComponentNamesRec rNames; bzero(&rNames,sizeof(XkbComponentNamesRec)); if (XkbDDXNamesFromRules(dev,rules,&defs,&rNames)) { - if (rNames.keymap) names->keymap= rNames.keymap; - if (rNames.keycodes) names->keycodes= rNames.keycodes; - if (rNames.types) names->types= rNames.types; - if (rNames.compat) names->compat= rNames.compat; - if (rNames.symbols) names->symbols= rNames.symbols; - if (rNames.geometry) names->geometry= rNames.geometry; + if (rNames.keymap) { + if (!names->keymap) + names->keymap = rNames.keymap; + else _XkbFree(rNames.keymap); + } + if (rNames.keycodes) { + if (!names->keycodes) + names->keycodes = rNames.keycodes; + else + _XkbFree(rNames.keycodes); + } + if (rNames.types) { + if (!names->types) + names->types = rNames.types; + else _XkbFree(rNames.types); + } + if (rNames.compat) { + if (!names->compat) + names->compat = rNames.compat; + else _XkbFree(rNames.compat); + } + if (rNames.symbols) { + if (!names->symbols) + names->symbols = rNames.symbols; + else _XkbFree(rNames.symbols); + } + if (rNames.geometry) { + if (!names->geometry) + names->geometry = rNames.geometry; + else _XkbFree(rNames.geometry); + } XkbSetRulesUsed(&defs); } } - if (cfgNames.keymap) names->keymap= cfgNames.keymap; - if (cfgNames.keycodes) names->keycodes= cfgNames.keycodes; - if (cfgNames.types) names->types= cfgNames.types; - if (cfgNames.compat) names->compat= cfgNames.compat; - if (cfgNames.symbols) names->symbols= cfgNames.symbols; - if (cfgNames.geometry) names->geometry= cfgNames.geometry; + if (cfgNames.keymap){ + if (names->keymap) _XkbFree(names->keymap); + names->keymap= cfgNames.keymap; + } + if (cfgNames.keycodes){ + if (names->keycodes) _XkbFree(names->keycodes); + names->keycodes= cfgNames.keycodes; + } + if (cfgNames.types) { + if (names->types) _XkbFree(names->types); + names->types= cfgNames.types; + } + if (cfgNames.compat) { + if (names->compat) _XkbFree(names->compat); + names->compat= cfgNames.compat; + } + if (cfgNames.symbols){ + if (names->symbols) _XkbFree(names->symbols); + names->symbols= cfgNames.symbols; + } + if (cfgNames.geometry) { + if (names->geometry) _XkbFree(names->geometry); + names->geometry= cfgNames.geometry; + } - if ((XkbDDXLoadKeymapByNames(dev,names,XkmAllIndicesMask,0, - &finfo,name,PATH_MAX))&& - (finfo.xkb!=NULL)) { + if (names->keymap) { + XkbComponentNamesRec tmpNames; + bzero(&tmpNames,sizeof(XkbComponentNamesRec)); + tmpNames.keymap = names->keymap; + ok = (Bool) XkbDDXLoadKeymapByNames(dev,&tmpNames,XkmAllIndicesMask,0, + &finfo,name,PATH_MAX); + } + if (!(ok && (finfo.xkb!=NULL))) + ok = (Bool) XkbDDXLoadKeymapByNames(dev,names,XkmAllIndicesMask,0, + &finfo,name,PATH_MAX); + + if (ok && (finfo.xkb!=NULL)) { XkbDescPtr xkb; int minKC,maxKC; @@ -758,6 +836,20 @@ XkbRF_VarDefsRec defs; _XkbFree(pSyms->map); pSyms->map= NULL; } + + if (names->keymap) _XkbFree(names->keymap); + names->keymap = NULL; + if (names->keycodes) _XkbFree(names->keycodes); + names->keycodes = NULL; + if (names->types) _XkbFree(names->types); + names->types = NULL; + if (names->compat) _XkbFree(names->compat); + names->compat = NULL; + if (names->geometry) _XkbFree(names->geometry); + names->geometry = NULL; + if (names->symbols) _XkbFree(names->symbols); + names->symbols = NULL; + return ok; } @@ -836,7 +928,7 @@ XkbFreeInfo(xkbi) #endif { if (xkbi->radioGroups) { - Xfree(xkbi->radioGroups); + _XkbFree(xkbi->radioGroups); xkbi->radioGroups= NULL; } if (xkbi->mouseKeyTimer) { @@ -868,7 +960,7 @@ XkbFreeInfo(xkbi) XkbFreeKeyboard(xkbi->desc,XkbAllComponentsMask,True); xkbi->desc= NULL; } - Xfree(xkbi); + _XkbFree(xkbi); return; } @@ -900,10 +992,37 @@ XkbProcessArguments(argc,argv,i) noXkbExtension= False; return 1; } + else if (strncmp(argv[i], "-xkbdir", 7) == 0) { + if(++i < argc) { +#if !defined(WIN32) && !defined(__UNIXOS2__) && !defined(__CYGWIN__) + if (getuid() != geteuid()) { + ErrorF("-xkbdir is not available for setuid X servers\n"); + return -1; + } else +#endif + { + if (strlen(argv[i]) < PATH_MAX) { + XkbBaseDirectory= argv[i]; + return 2; + } else { + ErrorF("-xkbdir pathname too long\n"); + return -1; + } + } + } + else { + return -1; + } + } else if (strncmp(argv[i], "-xkbmap", 7) == 0) { if(++i < argc) { - XkbInitialMap= argv[i]; - return 2; + if (strlen(argv[i]) < PATH_MAX) { + XkbInitialMap= argv[i]; + return 2; + } else { + ErrorF("-xkbmap pathname too long\n"); + return -1; + } } else { return -1; @@ -911,8 +1030,13 @@ XkbProcessArguments(argc,argv,i) } else if (strncmp(argv[i], "-xkbdb", 7) == 0) { if(++i < argc) { - XkbDB= argv[i]; - return 2; + if (strlen(argv[i]) < PATH_MAX) { + XkbDB= argv[i]; + return 2; + } else { + ErrorF("-xkbdb pathname too long\n"); + return -1; + } } else { return -1; @@ -988,7 +1112,6 @@ XkbUseMsg() ErrorF("-ar1 set XKB autorepeat delay\n"); ErrorF("-ar2 set XKB autorepeat interval\n"); ErrorF("-noloadxkb don't load XKB keymap description\n"); - ErrorF("-xkbcomp default keymap compiler\n"); ErrorF("-xkbdb file that contains default XKB keymaps\n"); ErrorF("-xkbmap XKB keyboard description to load on startup\n"); } diff --git a/xkb/xkbLEDs.c b/xkb/xkbLEDs.c index d3be89af7..33cf7bd9e 100644 --- a/xkb/xkbLEDs.c +++ b/xkb/xkbLEDs.c @@ -1,4 +1,4 @@ -/* $Xorg: xkbLEDs.c,v 1.3 2000/08/17 19:53:47 cpqbld Exp $ */ +/* $Xorg: xkbLEDs.c,v 1.4 2001/05/10 19:54:01 steve Exp $ */ /************************************************************ Copyright (c) 1995 by Silicon Graphics Computer Systems, Inc. @@ -24,6 +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/xkbLEDs.c,v 3.6 2001/11/23 19:21:36 dawes Exp $ */ #include <stdio.h> #include <ctype.h> @@ -37,8 +38,6 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "XI.h" #include "XKBsrv.h" -extern InputInfo inputInfo; - /***====================================================================***/ /* @@ -240,11 +239,10 @@ unsigned side_affected; XkbUpdateLedAutoState(dev,sli,side_affected,&ed,&changes,cause); affect|= side_affected; } - XkbSendNotification(dev,&changes,cause); - if (ed.reason) - XkbSendExtensionDeviceNotify(dev,cause->client,&ed); if (changes.state_changes || changes.ctrls.enabled_ctrls_changes) XkbUpdateAllDeviceIndicators(NULL,cause); + + XkbFlushLedEvents(dev,dev,sli,&ed,&changes,cause); return; } @@ -701,6 +699,14 @@ XkbFlushLedEvents(dev,kbd,sli,ed,changes,cause) XkbDDXUpdateDeviceIndicators(dev,sli,sli->effectiveState); XkbSendNotification(kbd,changes,cause); bzero((char *)changes,sizeof(XkbChangesRec)); + + if (XkbAX_NeedFeedback(kbd->key->xkbInfo->desc->ctrls, XkbAX_IndicatorFBMask)) { + if (sli->effectiveState) + /* it appears that the which parameter is not used */ + XkbDDXAccessXBeep(dev, _BEEP_LED_ON, XkbAccessXFeedbackMask); + else + XkbDDXAccessXBeep(dev, _BEEP_LED_OFF, XkbAccessXFeedbackMask); + } } if (ed && (ed->reason)) { if ((dev!=kbd)&&(ed->reason&XkbXI_IndicatorStateMask)) diff --git a/xkb/xkbPrKeyEv.c b/xkb/xkbPrKeyEv.c index 907cc3ab5..84af5f2f8 100644 --- a/xkb/xkbPrKeyEv.c +++ b/xkb/xkbPrKeyEv.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/programs/Xserver/xkb/xkbPrKeyEv.c,v 3.8 2001/01/17 22:37:15 dawes Exp $ */ #include <stdio.h> #include <math.h> @@ -53,6 +54,7 @@ KeyClassPtr keyc = keybd->key; XkbSrvInfoPtr xkbi; int key; XkbBehavior behavior; +unsigned ndx; xkbi= keyc->xkbInfo; key= xE->u.u.detail; @@ -106,34 +108,33 @@ XkbBehavior behavior; } break; case XkbKB_RadioGroup: - if ( xE->u.u.type == KeyRelease ) - return; - else { - unsigned ndx= (behavior.data&(~XkbKB_RGAllowNone)); - if ( ndx<xkbi->nRadioGroups ) { - XkbRadioGroupPtr rg; - - rg = &xkbi->radioGroups[ndx]; - if ( rg->currentDown == xE->u.u.detail ) { - if (behavior.data&XkbKB_RGAllowNone) { - xE->u.u.type = KeyRelease; - XkbHandleActions(keybd,keybd,xE,count); - rg->currentDown= 0; - } - return; - } - if ( rg->currentDown!=0 ) { - int key = xE->u.u.detail; - xE->u.u.type= KeyRelease; - xE->u.u.detail= rg->currentDown; + ndx= (behavior.data&(~XkbKB_RGAllowNone)); + if ( ndx<xkbi->nRadioGroups ) { + XkbRadioGroupPtr rg; + + if ( xE->u.u.type == KeyRelease ) + return; + + rg = &xkbi->radioGroups[ndx]; + if ( rg->currentDown == xE->u.u.detail ) { + if (behavior.data&XkbKB_RGAllowNone) { + xE->u.u.type = KeyRelease; XkbHandleActions(keybd,keybd,xE,count); - xE->u.u.type= KeyPress; - xE->u.u.detail= key; - } - rg->currentDown= key; + rg->currentDown= 0; + } + return; } - else ErrorF("InternalError! Illegal radio group %d\n",ndx); + if ( rg->currentDown!=0 ) { + int key = xE->u.u.detail; + xE->u.u.type= KeyRelease; + xE->u.u.detail= rg->currentDown; + XkbHandleActions(keybd,keybd,xE,count); + xE->u.u.type= KeyPress; + xE->u.u.detail= key; + } + rg->currentDown= key; } + else ErrorF("InternalError! Illegal radio group %d\n",ndx); break; case XkbKB_Overlay1: case XkbKB_Overlay2: { @@ -154,7 +155,11 @@ XkbBehavior behavior; break; default: ErrorF("unknown key behavior 0x%04x\n",behavior.type); +#if defined(MetroLink) + return; +#else break; +#endif } } XkbHandleActions(keybd,keybd,xE,count); diff --git a/xkb/xkbSwap.c b/xkb/xkbSwap.c index c9df88f7f..6a5bee3b9 100644 --- a/xkb/xkbSwap.c +++ b/xkb/xkbSwap.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/programs/Xserver/xkb/xkbSwap.c,v 3.2 2001/08/23 14:33:26 alanh Exp $ */ #include "stdio.h" #include "X.h" @@ -111,7 +112,7 @@ register int n; swaps(&stuff->selectAll,n); swaps(&stuff->affectMap,n); swaps(&stuff->map,n); - if (stuff->affectWhich&(~XkbMapNotifyMask)!=0) { + if ((stuff->affectWhich&(~XkbMapNotifyMask))!=0) { union { BOOL *b; CARD8 *c8; @@ -158,8 +159,8 @@ register int n; swaps(&from.c16[1],n); } else if (size==4) { - swapl(from.c32[0],n); - swapl(from.c32[1],n); + swapl(&from.c32[0],n); + swapl(&from.c32[1],n); } else { size= 2; diff --git a/xkb/xkbUtils.c b/xkb/xkbUtils.c index 05a817ba3..7d81d0169 100644 --- a/xkb/xkbUtils.c +++ b/xkb/xkbUtils.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/programs/Xserver/xkb/xkbUtils.c,v 3.13 2001/08/23 14:33:26 alanh Exp $ */ #include <stdio.h> #include <ctype.h> @@ -362,7 +363,7 @@ register unsigned key; XkbApplyCompatMapToKey(xkb,key,changes); } - if (changes->map.changed&XkbVirtualModMapMask|XkbModifierMapMask) { + if (changes->map.changed&(XkbVirtualModMapMask|XkbModifierMapMask)) { unsigned char newVMods[XkbNumVirtualMods]; register unsigned bit,i; unsigned present; @@ -550,15 +551,15 @@ CARD8 keysPerMod[XkbNumModifiers]; if (maxKeysPerMod>0) { tmp= maxKeysPerMod*XkbNumModifiers; if (keyc->modifierKeyMap==NULL) - keyc->modifierKeyMap= (KeyCode *)Xcalloc(tmp); + keyc->modifierKeyMap= (KeyCode *)_XkbCalloc(1, tmp); else if (keyc->maxKeysPerModifier<maxKeysPerMod) - keyc->modifierKeyMap= (KeyCode *)Xrealloc(keyc->modifierKeyMap,tmp); + keyc->modifierKeyMap= (KeyCode *)_XkbRealloc(keyc->modifierKeyMap,tmp); if (keyc->modifierKeyMap==NULL) FatalError("Couldn't allocate modifierKeyMap in UpdateCore\n"); bzero(keyc->modifierKeyMap,tmp); } else if ((keyc->maxKeysPerModifier>0)&&(keyc->modifierKeyMap!=NULL)) { - Xfree(keyc->modifierKeyMap); + _XkbFree(keyc->modifierKeyMap); keyc->modifierKeyMap= NULL; } keyc->maxKeysPerModifier= maxKeysPerMod; @@ -854,22 +855,22 @@ XkbComputeDerivedState(xkbi) { XkbStatePtr state= &xkbi->state; XkbControlsPtr ctrls= xkbi->desc->ctrls; -unsigned grp; +char grp; state->mods= (state->base_mods|state->latched_mods); state->mods|= state->locked_mods; state->lookup_mods= state->mods&(~ctrls->internal.mask); state->grab_mods= state->lookup_mods&(~ctrls->ignore_lock.mask); state->grab_mods|= - (state->base_mods|state->latched_mods&ctrls->ignore_lock.mask); + ((state->base_mods|state->latched_mods)&ctrls->ignore_lock.mask); grp= state->locked_group; - if (grp>=ctrls->num_groups) + if ((grp>=ctrls->num_groups) || (grp<0)) state->locked_group= XkbAdjustGroup(grp,ctrls); grp= state->locked_group+state->base_group+state->latched_group; - if (grp>=ctrls->num_groups) + if ((grp>=ctrls->num_groups) || (grp<0)) state->group= XkbAdjustGroup(grp,ctrls); else state->group= grp; XkbComputeCompatState(xkbi); @@ -1137,5 +1138,3 @@ XkbConvertCase(sym, lower, upper) break; } } - - diff --git a/xkb/xkbconfig.c b/xkb/xkbconfig.c index d2e67945e..c94b06feb 100644 --- a/xkb/xkbconfig.c +++ b/xkb/xkbconfig.c @@ -24,12 +24,11 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. ********************************************************/ +/* $XFree86: xc/lib/xkbfile/xkbconfig.c,v 3.7 2001/11/30 12:11:51 eich Exp $ */ #include <stdio.h> #include <ctype.h> -#ifndef X_NOT_STDC_ENV #include <stdlib.h> -#endif #include <X11/Xfuncs.h> @@ -274,6 +273,7 @@ int ch; #define _XkbCF_InternalMods 35 #define _XkbCF_GroupsWrap 36 +#define _XkbCF_InitialFeedback 37 static Bool #if NeedFunctionPrototypes @@ -343,6 +343,10 @@ AddAXTimeoutOptByName(rtrn,name,opts_rtrn) *opts_rtrn= XkbAX_IndicatorFBMask; else if (_XkbStrCaseCmp(name,"stickykeys")==0) *opts_rtrn= XkbAX_StickyKeysFBMask; + else if (_XkbStrCaseCmp(name,"twokeys")==0) + *opts_rtrn= XkbAX_TwoKeysMask; + else if (_XkbStrCaseCmp(name,"latchtolock")==0) + *opts_rtrn= XkbAX_LatchToLockMask; else if (_XkbStrCaseCmp(name,"slowkeysrelease")==0) *opts_rtrn= XkbAX_SKReleaseFBMask; else if (_XkbStrCaseCmp(name,"slowkeysreject")==0) @@ -524,9 +528,9 @@ int tok; XkbCFScanResultRec val; char ** str; int merge; -unsigned long * ctrls; -unsigned short * opts; -int * pival; +unsigned long * ctrls, ctrls_mask; +unsigned short * opts, opts_mask; +int * pival, sign; int onoff; XkbConfigUnboundModPtr last; unsigned what; @@ -611,7 +615,6 @@ unsigned what; break; case _XkbCF_InitialCtrls: rtrn->defined|= XkbCF_InitialCtrls; - opts= NULL; ctrls= NULL; if (tok==XkbCF_PlusEquals) ctrls= &rtrn->initial_ctrls; @@ -636,9 +639,10 @@ unsigned what; rtrn->error= XkbCF_ExpectedControl; return False; } - if (!AddCtrlByName(rtrn,val.str,ctrls)) { + if (!AddCtrlByName(rtrn,val.str,&ctrls_mask)) { return False; } + *ctrls |= ctrls_mask; tok= XkbCFScan(file,&val,rtrn); if ((tok!=XkbCF_EOL)&&(tok!=XkbCF_EOF)&&(tok!=XkbCF_Semi)) { if (tok!=XkbCF_Plus) { @@ -651,18 +655,6 @@ unsigned what; break; case _XkbCF_AccessXTimeoutCtrlsOn: case _XkbCF_AccessXTimeoutCtrlsOff: - case _XkbCF_AccessXTimeoutOptsOff: - case _XkbCF_AccessXTimeoutOptsOn: - if (field->field_id==_XkbCF_AccessXTimeoutOptsOff) - field->field_id= _XkbCF_AccessXTimeoutCtrlsOff; - else if (field->field_id==_XkbCF_AccessXTimeoutCtrlsOn) - field->field_id= _XkbCF_AccessXTimeoutCtrlsOn; - - if (field->field_id==_XkbCF_AccessXTimeoutCtrlsOff) - rtrn->defined|= XkbCF_AccessXTimeoutCtrlsOff; - else if (field->field_id==_XkbCF_AccessXTimeoutCtrlsOn) - rtrn->defined|= XkbCF_AccessXTimeoutCtrlsOn; - opts= NULL; if (tok==XkbCF_MinusEquals) { ctrls= &rtrn->axt_ctrls_ignore; @@ -697,9 +689,10 @@ unsigned what; rtrn->error= XkbCF_ExpectedControl; return False; } - if (!AddCtrlByName(rtrn,val.str,ctrls)) { - if (!AddAXTimeoutOptByName(rtrn,val.str,opts)) + if (!AddCtrlByName(rtrn,val.str,&ctrls_mask)) { + if (!AddAXTimeoutOptByName(rtrn,val.str,&opts_mask)) return False; + *opts |= opts_mask; if (field->field_id==_XkbCF_AccessXTimeoutCtrlsOff) { rtrn->defined|= XkbCF_AccessXTimeoutOptsOff; if (rtrn->replace_axt_ctrls_off) @@ -711,6 +704,94 @@ unsigned what; rtrn->replace_axt_opts_on= True; } } + else + *ctrls |= ctrls_mask; + tok= XkbCFScan(file,&val,rtrn); + if ((tok!=XkbCF_EOL)&&(tok!=XkbCF_EOF)&&(tok!=XkbCF_Semi)) { + if (tok!=XkbCF_Plus) { + rtrn->error= XkbCF_ExpectedOperator; + return False; + } + tok= XkbCFScan(file,&val,rtrn); + } + } + break; + case _XkbCF_InitialFeedback: + rtrn->defined|= XkbCF_InitialOpts; + opts= NULL; + if (tok==XkbCF_PlusEquals) + opts= &rtrn->initial_opts; + else if (tok==XkbCF_MinusEquals) + opts= &rtrn->initial_opts_clear; + else if (tok==XkbCF_Equals) { + opts= &rtrn->initial_opts; + rtrn->replace_initial_opts= True; + *opts= 0; + } + else { + rtrn->error= XkbCF_MissingEquals; + goto BAILOUT; + } + tok= XkbCFScan(file,&val,rtrn); + if ((tok==XkbCF_EOL)||(tok==XkbCF_Semi)||(tok==XkbCF_EOF)) { + rtrn->error= XkbCF_ExpectedAXOption; + return False; + } + while ((tok!=XkbCF_EOL)&&(tok!=XkbCF_Semi)&&(tok!=XkbCF_EOF)) { + if ((tok!=XkbCF_Ident)&&(tok!=XkbCF_String)) { + rtrn->error= XkbCF_ExpectedAXOption; + return False; + } + if (!AddAXTimeoutOptByName(rtrn,val.str,&opts_mask)) { + return False; + } + *opts |= opts_mask; + tok= XkbCFScan(file,&val,rtrn); + if ((tok!=XkbCF_EOL)&&(tok!=XkbCF_EOF)&&(tok!=XkbCF_Semi)) { + if (tok!=XkbCF_Plus) { + rtrn->error= XkbCF_ExpectedOperator; + return False; + } + tok= XkbCFScan(file,&val,rtrn); + } + } + break; + case _XkbCF_AccessXTimeoutOptsOff: + case _XkbCF_AccessXTimeoutOptsOn: + opts= NULL; + if (tok==XkbCF_MinusEquals) + opts= &rtrn->axt_opts_ignore; + else if ((tok==XkbCF_PlusEquals)||(tok==XkbCF_Equals)) { + if (field->field_id==_XkbCF_AccessXTimeoutOptsOff) { + opts= &rtrn->axt_opts_off; + if (tok==XkbCF_Equals) + rtrn->replace_axt_opts_off= True; + } + else { + opts= &rtrn->axt_opts_on; + if (tok==XkbCF_Equals) + rtrn->replace_axt_opts_on= True; + } + *opts = 0; + } + else { + rtrn->error= XkbCF_MissingEquals; + goto BAILOUT; + } + tok= XkbCFScan(file,&val,rtrn); + if ((tok==XkbCF_EOL)||(tok==XkbCF_Semi)||(tok==XkbCF_EOF)) { + rtrn->error= XkbCF_ExpectedControl; + return False; + } + while ((tok!=XkbCF_EOL)&&(tok!=XkbCF_Semi)&&(tok!=XkbCF_EOF)) { + if ((tok!=XkbCF_Ident)&&(tok!=XkbCF_String)) { + rtrn->error= XkbCF_ExpectedControl; + return False; + } + if (!AddAXTimeoutOptByName(rtrn,val.str,&opts_mask)) + return False; + *opts |= opts_mask; + tok= XkbCFScan(file,&val,rtrn); if ((tok!=XkbCF_EOL)&&(tok!=XkbCF_EOF)&&(tok!=XkbCF_Semi)) { if (tok!=XkbCF_Plus) { @@ -772,6 +853,13 @@ unsigned what; goto BAILOUT; } tok= XkbCFScan(file,&val,rtrn); + if (tok == XkbCF_Minus && field->field_id == _XkbCF_MouseKeysCurve) { + /* This can be a negative value */ + tok = XkbCFScan(file,&val,rtrn); + sign = -1; + } + else + sign = 1; if (tok!=XkbCF_Integer) { Bool ok= False; if ((onoff)&&(tok==XkbCF_Ident)&&(val.str!=NULL)) { @@ -789,8 +877,9 @@ unsigned what; goto BAILOUT; } } - *pival= val.ival; - rtrn->defined|= XkbCF_AccessXTimeout; + *pival= val.ival * sign; + if (field->field_id == _XkbCF_AccessXTimeout) + rtrn->defined|=XkbCF_AccessXTimeout; tok= XkbCFScan(file,&val,rtrn); if ((tok!=XkbCF_EOL)&&(tok!=XkbCF_Semi)&&(tok!=XkbCF_EOF)) { rtrn->error= XkbCF_ExpectedEOS; @@ -986,7 +1075,7 @@ unsigned int mask; ctrls->mk_max_speed= rtrn->mk_max_speed; if (rtrn->mk_curve>0) ctrls->mk_curve= rtrn->mk_curve; - if (rtrn->defined&XkbCF_AccessXTimeout) + if (rtrn->defined&XkbCF_AccessXTimeout && rtrn->ax_timeout > 0) ctrls->ax_timeout= rtrn->ax_timeout; /* any value set to both off and on is reset to ignore */ @@ -1120,13 +1209,18 @@ static XkbConfigFieldRec _XkbCFDfltFields[] = { { "axtctrlson", _XkbCF_AccessXTimeoutCtrlsOn }, { "accessxtimeoutctrlsoff",_XkbCF_AccessXTimeoutCtrlsOff }, { "axtctrlsoff",_XkbCF_AccessXTimeoutCtrlsOff }, + { "accessxtimeoutfeedbackon", _XkbCF_AccessXTimeoutOptsOn }, + { "axtfeedbackon", _XkbCF_AccessXTimeoutOptsOn }, + { "accessxtimeoutfeedbackoff", _XkbCF_AccessXTimeoutOptsOff }, + { "axtfeedbackoff", _XkbCF_AccessXTimeoutOptsOff }, { "ignorelockmods",_XkbCF_IgnoreLockMods }, { "ignorelockmodifiers",_XkbCF_IgnoreLockMods }, { "ignoregrouplock",_XkbCF_IgnoreGroupLock }, { "internalmods",_XkbCF_InternalMods }, { "internalmodifiers",_XkbCF_InternalMods }, { "outofrangegroups",_XkbCF_GroupsWrap }, - { "groups", _XkbCF_GroupsWrap } + { "groups", _XkbCF_GroupsWrap }, + { "feedback", _XkbCF_InitialFeedback }, }; #define _XkbCFNumDfltFields (sizeof(_XkbCFDfltFields)/sizeof(XkbConfigFieldRec)) @@ -1344,6 +1438,7 @@ BAILOUT: return False; } +/*ARGSUSED*/ void #if NeedFunctionPrototypes XkbCFReportError(FILE *file,char *name,int error,int line) @@ -1387,8 +1482,14 @@ char * msg; default: msg= "unknown error on line %d"; break; } +#ifndef XKB_IN_SERVER fprintf(file,msg,line); if (name) fprintf(file," of %s\n",name); else fprintf(file,"\n"); +#else + ErrorF(msg,line); + if (name) ErrorF(" of %s\n",name); + else ErrorF("\n"); +#endif return; } diff --git a/xkb/xkberrs.c b/xkb/xkberrs.c index 41df420b8..d12467ff7 100644 --- a/xkb/xkberrs.c +++ b/xkb/xkberrs.c @@ -24,15 +24,11 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. ********************************************************/ +/* $XFree86: xc/lib/xkbfile/xkberrs.c,v 3.5 2002/11/08 13:35:43 alanh Exp $ */ #include <stdio.h> #include <ctype.h> -#ifndef X_NOT_STDC_ENV #include <stdlib.h> -#endif -#include <X11/Xlib.h> -#include <X11/XKBlib.h> -#include <X11/extensions/XKBfile.h> char * _XkbErrMessages[] = { "success", /* _XkbSuccess */ diff --git a/xkb/xkbfmisc.c b/xkb/xkbfmisc.c index d07a704c3..8246390be 100644 --- a/xkb/xkbfmisc.c +++ b/xkb/xkbfmisc.c @@ -24,14 +24,11 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. ********************************************************/ +/* $XFree86: xc/lib/xkbfile/xkbmisc.c,v 1.4 2002/12/20 20:18:35 paulo Exp $ */ #include <stdio.h> #include <ctype.h> -#ifndef X_NOT_STDC_ENV #include <stdlib.h> -#endif - -#define XK_CYRILLIC #include <X11/Xos.h> #include <X11/Xfuncs.h> @@ -70,19 +67,78 @@ _XkbKSCheckCase(ks) #endif { unsigned set,rtrn; -unsigned char ch; - set= (ks & (~0xff)); - ch= (char)(ks&0xff); + set= (ks & (~0xff)) >> 8; rtrn= 0; switch (set) { case 0: /* latin 1 */ - if (((ch>=XK_A)&&(ch<=XK_Z))|| - ((ch>=XK_Agrave)&&(ch<=XK_THORN)&&(ch!=XK_multiply))) { + if (((ks>=XK_A)&&(ks<=XK_Z))|| + ((ks>=XK_Agrave)&&(ks<=XK_THORN)&&(ks!=XK_multiply))) { + rtrn|= _XkbKSUpper; + } + if (((ks>=XK_a)&&(ks<=XK_z))|| + ((ks>=XK_agrave)&&(ks<=XK_ydiaeresis))) { + rtrn|= _XkbKSLower; + } + break; + case 1: /* latin 2 */ + if (((ks>=XK_Aogonek)&&(ks<=XK_Zabovedot)&&(ks!=XK_breve))|| + ((ks>=XK_Racute)&&(ks<=XK_Tcedilla))) { + rtrn|= _XkbKSUpper; + } + if (((ks>=XK_aogonek)&&(ks<=XK_zabovedot)&&(ks!=XK_caron))|| + ((ks>=XK_racute)&&(ks<=XK_tcedilla))) { + rtrn|= _XkbKSLower; + } + break; + case 2: /* latin 3 */ + if (((ks>=XK_Hstroke)&&(ks<=XK_Jcircumflex))|| + ((ks>=XK_Cabovedot)&&(ks<=XK_Scircumflex))) { + rtrn|= _XkbKSUpper; + } + if (((ks>=XK_hstroke)&&(ks<=XK_jcircumflex))|| + ((ks>=XK_cabovedot)&&(ks<=XK_scircumflex))) { + rtrn|= _XkbKSLower; + } + break; + case 3: /* latin 4 */ + if (((ks>=XK_Rcedilla)&&(ks<=XK_Tslash))|| + (ks==XK_ENG)|| + ((ks>=XK_Amacron)&&(ks<=XK_Umacron))) { + rtrn|= _XkbKSUpper; + } + if (((ks>=XK_rcedilla)&&(ks<=XK_tslash))|| + (ks==XK_eng)|| + ((ks>=XK_amacron)&&(ks<=XK_umacron))) { + rtrn|= _XkbKSLower; + } + break; + case 18: /* latin 8 */ + if ((ks==XK_Babovedot)|| + ((ks>=XK_Dabovedot)&&(ks<=XK_Wacute))|| + ((ks>=XK_Ygrave)&&(ks<=XK_Fabovedot))|| + (ks==XK_Mabovedot)|| + (ks==XK_Pabovedot)|| + (ks==XK_Sabovedot)|| + (ks==XK_Wdiaeresis)|| + ((ks>=XK_Wcircumflex)&&(ks<=XK_Ycircumflex))) { + rtrn|= _XkbKSUpper; + } + if ((ks==XK_babovedot)|| + (ks==XK_dabovedot)|| + (ks==XK_fabovedot)|| + (ks==XK_mabovedot)|| + ((ks>=XK_wgrave)&&(ks<=XK_wacute))|| + (ks==XK_ygrave)|| + ((ks>=XK_wdiaeresis)&&(ks<=XK_ycircumflex))) { + rtrn|= _XkbKSLower; + } + break; + case 19: /* latin 9 */ + if ((ks==XK_OE)||(ks==XK_Ydiaeresis)) { rtrn|= _XkbKSUpper; } - if (((ch>=XK_a)&&(ch<=XK_z))|| - ((ch>=XK_agrave)&&(ch<=XK_ydiaeresis))) { + if (ks==XK_oe) { rtrn|= _XkbKSLower; } break; diff --git a/xkb/xkbout.c b/xkb/xkbout.c index 845325358..fd7603b03 100644 --- a/xkb/xkbout.c +++ b/xkb/xkbout.c @@ -24,12 +24,11 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. ********************************************************/ +/* $XFree86: xc/lib/xkbfile/xkbout.c,v 3.9 2001/10/28 03:32:47 tsi Exp $ */ #include <stdio.h> #include <ctype.h> -#ifndef X_NOT_STDC_ENV #include <stdlib.h> -#endif #include <X11/Xfuncs.h> #ifndef XKB_IN_SERVER @@ -849,7 +848,7 @@ WriteXKBSection(file,dpy,s,geom) { register int i; XkbRowPtr row; -int dfltKeyColor; +int dfltKeyColor = 0; fprintf(file," section \"%s\" {\n", XkbAtomText(dpy,s->name,XkbXKBFile)); @@ -1100,6 +1099,7 @@ XkbDescPtr xkb; xkb= result->xkb; fprintf(file,"xkb_layout {\n"); ok= XkbWriteXKBKeycodes(file,result,False,showImplicit,addOn,priv); + ok= ok&&XkbWriteXKBKeyTypes(file,result,False,showImplicit,addOn,priv); ok= ok&&XkbWriteXKBSymbols(file,result,False,showImplicit,addOn,priv); if (xkb->geom) ok= ok&&XkbWriteXKBGeometry(file,result,False,showImplicit,addOn,priv); @@ -1157,7 +1157,7 @@ XkbWriteXKBFile(out,result,showImplicit,addOn,priv) void * priv; #endif { -Bool ok; +Bool ok = False; Bool (*func)( #if NeedFunctionPrototypes FILE * /* file */, @@ -1167,7 +1167,7 @@ Bool (*func)( XkbFileAddOnFunc /* addOn */, void * /* priv */ #endif -); +) = NULL; switch (result->type) { case XkmSemanticsFile: @@ -1205,12 +1205,8 @@ Bool (*func)( _XkbLibError(_XkbErrFileCannotOpen,"XkbWriteXkbFile",0); ok= False; } - else { + else if (func) { ok= (*func)(out,result,True,showImplicit,addOn,priv); } - if (!ok) { - return False; - } - return True; + return ok; } - diff --git a/xkb/xkbtext.c b/xkb/xkbtext.c index 18c07a18a..d233af0b4 100644 --- a/xkb/xkbtext.c +++ b/xkb/xkbtext.c @@ -24,12 +24,11 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. ********************************************************/ +/* $XFree86: xc/lib/xkbfile/xkbtext.c,v 3.11 2002/12/21 18:49:02 paulo Exp $ */ #include <stdio.h> #include <ctype.h> -#ifndef X_NOT_STDC_ENV #include <stdlib.h> -#endif #include <X11/Xos.h> @@ -403,7 +402,7 @@ static char buf[32],*rtrn; if (sym==NoSymbol) strcpy(rtrn=buf,"NoSymbol"); else if ((rtrn=XKeysymToString(sym))==NULL) - sprintf(rtrn=buf,"0x%x",sym); + sprintf(rtrn=buf, "0x%lx", (long)sym); else if (format==XkbCFile) { sprintf(buf,"XK_%s",rtrn); rtrn= buf; @@ -412,7 +411,7 @@ static char buf[32],*rtrn; #else /* def XKB_IN_SERVER */ if (sym==NoSymbol) strcpy(rtrn=buf,"NoSymbol"); - else sprintf(rtrn=buf,"0x%x",sym); + else sprintf(rtrn=buf, "0x%lx", (long)sym); return rtrn; #endif /* XKB_IN_SERVER */ } @@ -589,7 +588,7 @@ int len,plen,slen; if ((detail&XkbAllNewKeyboardEventsMask)==0) { - char * tmp; + char *tmp = ""; if (format==XkbCFile) tmp= "0"; else if (format==XkbMessage) tmp= "none"; buf= tbGetBuffer(strlen(tmp)+1); @@ -874,7 +873,7 @@ char *rtrn; } return rtrn; } - sprintf(buf,"0x%x",type); + sprintf(buf,"Private"); return buf; } @@ -1500,7 +1499,7 @@ int sz; if (format==XkbCFile) { sprintf(buf, - "{ %20s, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x }", + "{ %20s, { 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x } }", XkbActionTypeText(action->type,XkbCFile), action->any.data[0],action->any.data[1],action->any.data[2], action->any.data[3],action->any.data[4],action->any.data[5], @@ -1543,7 +1542,7 @@ char buf[256],*tmp; permanent=((behavior->type&XkbKB_Permanent)!=0); if (type==XkbKB_Lock) { - sprintf(buf,"lock= %s,",(permanent?"Permanent":"True")); + sprintf(buf,"lock= %s",(permanent?"Permanent":"True")); } else if (type==XkbKB_RadioGroup) { int g; diff --git a/xkb/xkmread.c b/xkb/xkmread.c index 7a4a2b429..af6cc3eba 100644 --- a/xkb/xkmread.c +++ b/xkb/xkmread.c @@ -24,6 +24,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. ********************************************************/ +/* $XFree86: xc/lib/xkbfile/xkmread.c,v 1.6 2002/02/13 22:09:42 herrb Exp $ */ #include <stdio.h> @@ -32,9 +33,7 @@ #ifndef XKB_IN_SERVER -#ifndef X_NOT_STDC_ENV #include <stdlib.h> -#endif #include <X11/Xlib.h> #include <X11/keysym.h> @@ -172,7 +171,7 @@ XkmGetCARD32(file,pNRead) int * pNRead; #endif { -unsigned long val; +CARD32 val; if ((fread(&val,4,1,file)==1)&&(pNRead)) (*pNRead)+= 4; @@ -797,13 +796,13 @@ XkbDescPtr xkb; xkb->server->explicit[i]|= XkbExplicitAutoRepeatMask; } xkb->map->modmap[i]= wireMap.modifier_map; - if (wireMap.num_groups>0) { + if (XkbNumGroups(wireMap.num_groups)>0) { KeySym *sym; int nSyms; - if (wireMap.num_groups>xkb->ctrls->num_groups) + if (XkbNumGroups(wireMap.num_groups)>xkb->ctrls->num_groups) xkb->ctrls->num_groups= wireMap.num_groups; - nSyms= wireMap.num_groups*wireMap.width; + nSyms= XkbNumGroups(wireMap.num_groups)*wireMap.width; sym= XkbResizeKeySyms(xkb,i,nSyms); if (!sym) return -1; @@ -820,7 +819,7 @@ XkbDescPtr xkb; xkb->server->explicit[i]|= XkbExplicitInterpretMask; } } - for (g=0;g<wireMap.num_groups;g++) { + for (g=0;g<XkbNumGroups(wireMap.num_groups);g++) { if (((xkb->server->explicit[i]&(1<<g))==0)||(type[g]==NULL)) { KeySym *tmpSyms; tmpSyms= XkbKeySymsPtr(xkb,i)+(wireMap.width*g); |