From 2db519141865cd504351aabf042db5bdf2ac5d96 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Sun, 24 Jun 2018 23:33:33 +0200 Subject: Check nxagentXkbInfo.EventBase before use --- nx-X11/programs/Xserver/hw/nxagent/Events.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Events.c b/nx-X11/programs/Xserver/hw/nxagent/Events.c index 94480c45c..4c85145a9 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Events.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Events.c @@ -2782,7 +2782,8 @@ int nxagentHandleXkbKeyboardStateEvent(XEvent *X) { XkbEvent *xkbev = (XkbEvent *) X; - if (xkbev -> type == nxagentXkbInfo.EventBase + XkbEventCode && + if (nxagentXkbInfo.EventBase != -1 && + xkbev -> type == nxagentXkbInfo.EventBase + XkbEventCode && xkbev -> any.xkb_type == XkbStateNotify) { #ifdef TEST @@ -3815,6 +3816,11 @@ int nxagentInitXkbKeyboardState(void) XkbEvent *xkbev = (XkbEvent *) &X; + if (nxagentXkbInfo.EventBase == -1) + { + return 1; + } + #ifdef TEST fprintf(stderr, "%s: Initializing XKB state.\n", __func__); #endif -- cgit v1.2.3 From 9808c66ec37d5d99f58bdb6136ae96381cb9cfc8 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 29 Jun 2018 22:34:32 +0200 Subject: Lift xkb to XORG-1.2.0 state --- nx-X11/programs/Xserver/hw/nxagent/Keyboard.c | 2 +- nx-X11/programs/Xserver/include/xkbfile.h | 32 +- nx-X11/programs/Xserver/include/xkbsrv.h | 3 +- nx-X11/programs/Xserver/xkb/Imakefile | 8 +- nx-X11/programs/Xserver/xkb/XKBMisc.c | 7 +- nx-X11/programs/Xserver/xkb/ddxBeep.c | 1 + nx-X11/programs/Xserver/xkb/ddxKillSrv.c | 5 - nx-X11/programs/Xserver/xkb/ddxList.c | 13 +- nx-X11/programs/Xserver/xkb/ddxLoad.c | 1 - nx-X11/programs/Xserver/xkb/ddxPrivate.c | 5 - nx-X11/programs/Xserver/xkb/ddxVT.c | 5 - nx-X11/programs/Xserver/xkb/maprules.c | 16 +- nx-X11/programs/Xserver/xkb/xkb.c | 294 +++--- nx-X11/programs/Xserver/xkb/xkbActions.c | 4 - nx-X11/programs/Xserver/xkb/xkbEvents.c | 4 + nx-X11/programs/Xserver/xkb/xkbInit.c | 8 - nx-X11/programs/Xserver/xkb/xkbLEDs.c | 18 +- nx-X11/programs/Xserver/xkb/xkbPrKeyEv.c | 4 - nx-X11/programs/Xserver/xkb/xkbUtils.c | 4 +- nx-X11/programs/Xserver/xkb/xkbfmisc.c | 456 ++++++++- nx-X11/programs/Xserver/xkb/xkbout.c | 1047 +++++++++++++++++++ nx-X11/programs/Xserver/xkb/xkbtext.c | 1325 +++++++++++++++++++++++++ nx-X11/programs/Xserver/xkb/xkmread.c | 94 +- 23 files changed, 2979 insertions(+), 377 deletions(-) create mode 100644 nx-X11/programs/Xserver/xkb/xkbout.c create mode 100644 nx-X11/programs/Xserver/xkb/xkbtext.c diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c index 6a146676e..c6998e8be 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c @@ -155,7 +155,7 @@ extern Status XkbGetControls( #define XKB_CONFIG_FILE_X2GO "/etc/x2go/x2goagent.keyboard" #endif #ifndef XKB_DFLT_RULES_FILE -#define XKB_DFLT_RULES_FILE "xfree86" +#define XKB_DFLT_RULES_FILE "base" #endif #ifndef XKB_ALTS_RULES_FILE #define XKB_ALTS_RULES_FILE "xorg" diff --git a/nx-X11/programs/Xserver/include/xkbfile.h b/nx-X11/programs/Xserver/include/xkbfile.h index e99de6c9c..2b0224400 100644 --- a/nx-X11/programs/Xserver/include/xkbfile.h +++ b/nx-X11/programs/Xserver/include/xkbfile.h @@ -10,19 +10,19 @@ fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting - documentation, and that the name of Silicon Graphics not be - used in advertising or publicity pertaining to distribution + documentation, and that the name of Silicon Graphics not be + used in advertising or publicity pertaining to distribution of the software without specific prior written permission. - Silicon Graphics makes no representation about the suitability + Silicon Graphics makes no representation about the suitability of this software for any purpose. It is provided "as is" without any express or implied warranty. - - SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS - SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + + SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS + SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL - DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE + GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. @@ -83,9 +83,9 @@ typedef void (*XkbFileAddOnFunc)( #define _XkbErrXReqFailure 25 #define _XkbErrBadImplementation 26 -extern char * _XkbErrMessages[]; +extern const char * _XkbErrMessages[]; extern unsigned _XkbErrCode; -extern char * _XkbErrLocation; +extern const char * _XkbErrLocation; extern unsigned _XkbErrData; /***====================================================================***/ @@ -233,12 +233,14 @@ extern Bool XkbLookupGroupAndLevel( /***====================================================================***/ - -/***====================================================================***/ +extern char * XkbAtomGetString( + Display * /* dpy */, + Atom /* atm */ +); extern Atom XkbInternAtom( Display * /* dpy */, - char * /* name */, + char * /* name */, Bool /* onlyIfExists */ ); @@ -272,7 +274,7 @@ typedef struct _XkbDrawable { XkbSectionPtr section; } u; struct _XkbDrawable * next; -} XkbDrawableRec,*XkbDrawablePtr; +} XkbDrawableRec,*XkbDrawablePtr; extern XkbDrawablePtr XkbGetOrderedDrawables( diff --git a/nx-X11/programs/Xserver/include/xkbsrv.h b/nx-X11/programs/Xserver/include/xkbsrv.h index 9f9ccc5c3..a3f8718cb 100644 --- a/nx-X11/programs/Xserver/include/xkbsrv.h +++ b/nx-X11/programs/Xserver/include/xkbsrv.h @@ -267,7 +267,8 @@ extern int XkbEventBase; extern int XkbDisableLockActions; extern char * XkbBaseDirectory; extern char * XkbBinDirectory; -extern char * XkbInitialMap; +extern int _XkbClientMajor; +extern int _XkbClientMinor; extern unsigned int XkbXIUnsupported; extern Bool noXkbExtension; diff --git a/nx-X11/programs/Xserver/xkb/Imakefile b/nx-X11/programs/Xserver/xkb/Imakefile index 5acd977f0..21d631acd 100644 --- a/nx-X11/programs/Xserver/xkb/Imakefile +++ b/nx-X11/programs/Xserver/xkb/Imakefile @@ -26,13 +26,13 @@ XKB_DDXDEFS = XkbServerDefines ddxList.o ddxDevBtn.o ddxPrivate.o SRCS = xkb.c xkbUtils.c xkbEvents.c xkbAccessX.c xkbSwap.c \ xkbLEDs.c xkbInit.c xkbActions.c xkbPrKeyEv.c \ - xkmread.c xkbfmisc.c xkberrs.c maprules.c \ - XKBMisc.c XKBMAlloc.c XKBAlloc.c XKBGAlloc.c \ + xkmread.c xkbtext.c xkbfmisc.c xkberrs.c maprules.c \ + XKBMisc.c XKBMAlloc.c XKBAlloc.c XKBGAlloc.c xkbout.c \ $(XKBXI_SRCS) $(DDX_SRCS) OBJS = xkb.o xkbUtils.o xkbEvents.o xkbAccessX.o xkbSwap.o \ xkbLEDs.o xkbInit.o xkbActions.o xkbPrKeyEv.o \ - xkmread.o xkbfmisc.o xkberrs.o maprules.o \ - XKBMisc.o XKBMAlloc.o XKBAlloc.o XKBGAlloc.o \ + xkmread.o xkbtext.o xkbfmisc.o xkberrs.o maprules.o \ + XKBMisc.o XKBMAlloc.o XKBAlloc.o XKBGAlloc.o xkbout.o \ $(XKBXI_OBJS) $(DDX_OBJS) INCLUDES = -I../include -I$(XINCLUDESRC) -I$(EXTINCSRC) -I$(SERVERSRC)/Xext \ -I$(SERVERSRC)/mi $(XF86INCLUDES) \ diff --git a/nx-X11/programs/Xserver/xkb/XKBMisc.c b/nx-X11/programs/Xserver/xkb/XKBMisc.c index 98f11a2be..2c5cf42c7 100644 --- a/nx-X11/programs/Xserver/xkb/XKBMisc.c +++ b/nx-X11/programs/Xserver/xkb/XKBMisc.c @@ -366,8 +366,11 @@ unsigned changed,tmp; unsigned int new_vmodmask; changed|= XkbKeyActionsMask; pActs= XkbResizeKeyActions(xkb,key,nSyms); - if (!pActs) + if (!pActs) { + if (nSyms > IBUF_SIZE) + free(interps); return False; + } new_vmodmask= 0; for (n=0;nmap) || - (!xkb->map->types)||((groups&XkbAllGroupsMask)==0)|| + (!xkb->map->types)||(!newTypesIn)||((groups&XkbAllGroupsMask)==0)|| (nGroups>XkbNumKbdGroups)) { return BadMatch; } diff --git a/nx-X11/programs/Xserver/xkb/ddxBeep.c b/nx-X11/programs/Xserver/xkb/ddxBeep.c index fa4af7456..9f55ff3b8 100644 --- a/nx-X11/programs/Xserver/xkb/ddxBeep.c +++ b/nx-X11/programs/Xserver/xkb/ddxBeep.c @@ -38,6 +38,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include + /*#define FALLING_TONE 1*/ /*#define RISING_TONE 1*/ #define FALLING_TONE 10 diff --git a/nx-X11/programs/Xserver/xkb/ddxKillSrv.c b/nx-X11/programs/Xserver/xkb/ddxKillSrv.c index c581d4201..3a8ffdd57 100644 --- a/nx-X11/programs/Xserver/xkb/ddxKillSrv.c +++ b/nx-X11/programs/Xserver/xkb/ddxKillSrv.c @@ -28,10 +28,6 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #endif -#ifdef HAVE_XORG_CONFIG_H -#include -#endif - #include #include #include @@ -40,7 +36,6 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "scrnintstr.h" #include "windowstr.h" #include -#include int XkbDDXTerminateServer(DeviceIntPtr dev,KeyCode key,XkbAction *act) diff --git a/nx-X11/programs/Xserver/xkb/ddxList.c b/nx-X11/programs/Xserver/xkb/ddxList.c index 6023366da..e48e28da4 100644 --- a/nx-X11/programs/Xserver/xkb/ddxList.c +++ b/nx-X11/programs/Xserver/xkb/ddxList.c @@ -164,8 +164,6 @@ char tmpname[PATH_MAX]; if ((list->pattern[what][0]=='*')&&(list->pattern[what][1]=='\0')) { buf = Xprintf("%s/%s.dir",XkbBaseDirectory,componentDirs[what]); in= fopen(buf,"r"); - free (buf); - buf = NULL; } if (!in) { haveDir= False; @@ -181,8 +179,6 @@ char tmpname[PATH_MAX]; if ((list->pattern[what][0]=='*')&&(list->pattern[what][1]=='\0')) { buf = Xprintf("%s.dir",componentDirs[what]); in= fopen(buf,"r"); - free (buf); - buf = NULL; } if (!in) { haveDir= False; @@ -219,6 +215,13 @@ char tmpname[PATH_MAX]; return BadImplementation; } list->nFound[what]= 0; + if (buf) { + free(buf); + buf = NULL; + } + buf = malloc(PATH_MAX * sizeof(char)); + if (!buf) + return BadAlloc; while ((status==Success)&&((tmp=fgets(buf,PATH_MAX,in))!=NULL)) { unsigned flags; register unsigned int i; @@ -263,7 +266,7 @@ char tmpname[PATH_MAX]; #ifndef WIN32 if (haveDir) fclose(in); - else if ((rval=pclose(in))!=0) { + else if ((rval=Pclose(in))!=0) { if (xkbDebugFlags) ErrorF("xkbcomp returned exit code %d\n",rval); } diff --git a/nx-X11/programs/Xserver/xkb/ddxLoad.c b/nx-X11/programs/Xserver/xkb/ddxLoad.c index 83db4350c..f710af285 100644 --- a/nx-X11/programs/Xserver/xkb/ddxLoad.c +++ b/nx-X11/programs/Xserver/xkb/ddxLoad.c @@ -565,7 +565,6 @@ char *cmd = NULL,file[PATH_MAX],xkm_output_dir[PATH_MAX],*map,*outFile; char *xkbbasedir = XkbBaseDirectory; char *xkbbindir = XkbBinDirectory; #endif - cmd = Xprintf("\"%s" PATHSEPARATOR "xkbcomp\" -w %d \"-R%s\" -xkm %s%s -em1 %s -emp %s -eml %s keymap/%s \"%s%s.xkm\"", xkbbindir, ((xkbDebugFlags<2)?1:((xkbDebugFlags>10)?10:(int)xkbDebugFlags)), diff --git a/nx-X11/programs/Xserver/xkb/ddxPrivate.c b/nx-X11/programs/Xserver/xkb/ddxPrivate.c index 0064cabde..f602f0abc 100644 --- a/nx-X11/programs/Xserver/xkb/ddxPrivate.c +++ b/nx-X11/programs/Xserver/xkb/ddxPrivate.c @@ -3,11 +3,6 @@ #include #endif -#ifdef HAVE_XORG_CONFIG_H -#include -#endif - -#include #include #include "windowstr.h" #include diff --git a/nx-X11/programs/Xserver/xkb/ddxVT.c b/nx-X11/programs/Xserver/xkb/ddxVT.c index 6c61de07f..f0edddc5e 100644 --- a/nx-X11/programs/Xserver/xkb/ddxVT.c +++ b/nx-X11/programs/Xserver/xkb/ddxVT.c @@ -28,10 +28,6 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #endif -#ifdef HAVE_XORG_CONFIG_H -#include -#endif - #include #include #include @@ -40,7 +36,6 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "scrnintstr.h" #include "windowstr.h" #include -#include int XkbDDXSwitchScreen(DeviceIntPtr dev,KeyCode key,XkbAction *act) diff --git a/nx-X11/programs/Xserver/xkb/maprules.c b/nx-X11/programs/Xserver/xkb/maprules.c index c64e1f796..295f1acf6 100644 --- a/nx-X11/programs/Xserver/xkb/maprules.c +++ b/nx-X11/programs/Xserver/xkb/maprules.c @@ -58,12 +58,6 @@ #define PR_DEBUG2(s,a,b) #endif -#ifdef NEED_STRCASECMP -extern int _XkbStrCaseCmp(char *s1, char *s2); -#else -#define _XkbStrCaseCmp strcasecmp -#endif - /***====================================================================***/ #define DFLT_LINE_SIZE 128 @@ -1088,20 +1082,20 @@ int len,headingtype,extra_ndx = 0; for ( ; GetInputLine(file,&line,False); line.num_line= 0) { if (line.line[0]=='!') { tok = strtok(&(line.line[1]), " \t"); - if (_XkbStrCaseCmp(tok,"model") == 0) + if (strcasecmp(tok,"model") == 0) headingtype = HEAD_MODEL; - else if (_XkbStrCaseCmp(tok,"layout") == 0) + else if (strcasecmp(tok,"layout") == 0) headingtype = HEAD_LAYOUT; - else if (_XkbStrCaseCmp(tok,"variant") == 0) + else if (strcasecmp(tok,"variant") == 0) headingtype = HEAD_VARIANT; - else if (_XkbStrCaseCmp(tok,"option") == 0) + else if (strcasecmp(tok,"option") == 0) headingtype = HEAD_OPTION; else { int i; headingtype = HEAD_EXTRA; extra_ndx= -1; for (i=0;(inum_extra)&&(extra_ndx<0);i++) { - if (!_XkbStrCaseCmp(tok,rules->extra_names[i])) + if (!strcasecmp(tok,rules->extra_names[i])) extra_ndx= i; } if (extra_ndx<0) { diff --git a/nx-X11/programs/Xserver/xkb/xkb.c b/nx-X11/programs/Xserver/xkb/xkb.c index 2138497b7..3de41c086 100644 --- a/nx-X11/programs/Xserver/xkb/xkb.c +++ b/nx-X11/programs/Xserver/xkb/xkb.c @@ -47,13 +47,6 @@ static int XkbKeyboardErrorCode; CARD32 xkbDebugFlags = 0; static CARD32 xkbDebugCtrls = 0; - -#ifndef XKB_SRV_UNSUPPORTED_XI_FEATURES -#define XKB_SRV_UNSUPPORTED_XI_FEATURES XkbXI_KeyboardsMask -#endif - -unsigned XkbXIUnsupported= XKB_SRV_UNSUPPORTED_XI_FEATURES; - static RESTYPE RT_XKBCLIENT; /***====================================================================***/ @@ -168,11 +161,6 @@ ProcXkbUseExtension(ClientPtr client) } else supported = 1; -#ifdef XKB_SWAPPING_BUSTED - if (client->swapped) - supported= 0; -#endif - if ((supported) && (!(client->xkbClientFlags&_XkbClientInitialized))) { client->xkbClientFlags= _XkbClientInitialized; client->vMajor= stuff->wantedMajor; @@ -2891,7 +2879,6 @@ ProcXkbGetNamedIndicator(ClientPtr client) register int i = 0; XkbSrvLedInfoPtr sli; XkbIndicatorMapPtr map = NULL; - Bool supported; REQUEST(xkbGetNamedIndicatorReq); REQUEST_SIZE_MATCH(xkbGetNamedIndicatorReq); @@ -2906,25 +2893,15 @@ ProcXkbGetNamedIndicator(ClientPtr client) if (!sli) return BadAlloc; - supported= True; - if (XkbXIUnsupported&XkbXI_IndicatorsMask) { - if ((dev!=(DeviceIntPtr)LookupKeyboardDevice())|| - ((sli->flags&XkbSLI_IsDefault)==0)) { - supported= False; - } - } - - if (supported) { - i= 0; - map= NULL; - if ((sli->names)&&(sli->maps)) { - for (i=0;iindicator==sli->names[i]) { - map= &sli->maps[i]; - break; - } - } - } + i= 0; + map= NULL; + if ((sli->names)&&(sli->maps)) { + for (i=0;iindicator==sli->names[i]) { + map= &sli->maps[i]; + break; + } + } } rep.type= X_Reply; @@ -2932,7 +2909,7 @@ ProcXkbGetNamedIndicator(ClientPtr client) rep.sequenceNumber = client->sequence; rep.deviceID = dev->id; rep.indicator= stuff->indicator; - if ((map!=NULL)&&(supported)) { + if (map!=NULL) { rep.found= True; rep.on= ((sli->effectiveState&(1<physIndicators&(1<swapped ) { swapl(&rep.length); @@ -2971,21 +2948,6 @@ ProcXkbGetNamedIndicator(ClientPtr client) } WriteToClient(client,SIZEOF(xkbGetNamedIndicatorReply), &rep); - if (!supported) { - xkbExtensionDeviceNotify edev; - - bzero(&edev,sizeof(xkbExtensionDeviceNotify)); - edev.reason= XkbXI_UnsupportedFeatureMask; - edev.ledClass= stuff->ledClass; - edev.ledID= stuff->ledID; - edev.ledsDefined= sli->namesPresent|sli->mapsPresent; - edev.ledState= sli->effectiveState; - edev.firstBtn= 0; - edev.nBtns= 0; - edev.unsupported= XkbXIUnsupported&XkbXI_IndicatorsMask; - edev.supported= XkbXI_AllFeaturesMask&(~XkbXIUnsupported); - XkbSendExtensionDeviceNotify(dev,client,&edev); - } return client->noClientException; } @@ -3020,24 +2982,6 @@ ProcXkbSetNamedIndicator(ClientPtr client) if (!sli) return BadAlloc; - if (XkbXIUnsupported&XkbXI_IndicatorsMask) { - if ((dev!=(DeviceIntPtr)LookupKeyboardDevice())|| - ((sli->flags&XkbSLI_IsDefault)==0)) { - bzero(&ed,sizeof(xkbExtensionDeviceNotify)); - ed.reason= XkbXI_UnsupportedFeatureMask; - ed.ledClass= stuff->ledClass; - ed.ledID= stuff->ledID; - ed.ledsDefined= sli->namesPresent|sli->mapsPresent; - ed.ledState= sli->effectiveState; - ed.firstBtn= 0; - ed.nBtns= 0; - ed.unsupported= XkbXIUnsupported&XkbXI_IndicatorsMask; - ed.supported= XkbXI_AllFeaturesMask&(~XkbXIUnsupported); - XkbSendExtensionDeviceNotify(dev,client,&ed); - return client->noClientException; - } - } - statec= mapc= namec= 0; map= NULL; if (sli->names && sli->maps) { @@ -3052,7 +2996,8 @@ ProcXkbSetNamedIndicator(ClientPtr client) if (!stuff->createMap) return client->noClientException; for (led=0,map=NULL;(lednames[led]==None)&&(!XkbIM_InUse(&sli->maps[led]))) { + if ((sli->names)&&(sli->maps)&&(sli->names[led]==None)&& + (!XkbIM_InUse(&sli->maps[led]))) { map= &sli->maps[led]; sli->names[led]= stuff->indicator; break; @@ -3261,118 +3206,121 @@ char * desc; start = desc = (char *)malloc(length); if ( !start ) return BadAlloc; - if (which&XkbKeycodesNameMask) { - *((CARD32 *)desc)= xkb->names->keycodes; - if (client->swapped) { + if (xkb->names) { + if (which&XkbKeycodesNameMask) { + *((CARD32 *)desc)= xkb->names->keycodes; + if (client->swapped) { swapl((int *)desc); - } - desc+= 4; - } - if (which&XkbGeometryNameMask) { - *((CARD32 *)desc)= xkb->names->geometry; - if (client->swapped) { + } + desc+= 4; + } + if (which&XkbGeometryNameMask) { + *((CARD32 *)desc)= xkb->names->geometry; + if (client->swapped) { swapl((int *)desc); - } - desc+= 4; - } - if (which&XkbSymbolsNameMask) { - *((CARD32 *)desc)= xkb->names->symbols; - if (client->swapped) { + } + desc+= 4; + } + if (which&XkbSymbolsNameMask) { + *((CARD32 *)desc)= xkb->names->symbols; + if (client->swapped) { swapl((int *)desc); - } - desc+= 4; - } - if (which&XkbPhysSymbolsNameMask) { - register CARD32 *atm= (CARD32 *)desc; - atm[0]= (CARD32)xkb->names->phys_symbols; - if (client->swapped) { + } + desc+= 4; + } + if (which&XkbPhysSymbolsNameMask) { + register CARD32 *atm= (CARD32 *)desc; + atm[0]= (CARD32)xkb->names->phys_symbols; + if (client->swapped) { swapl(&atm[0]); - } - desc+= 4; - } - if (which&XkbTypesNameMask) { - *((CARD32 *)desc)= (CARD32)xkb->names->types; - if (client->swapped) { + } + desc+= 4; + } + if (which&XkbTypesNameMask) { + *((CARD32 *)desc)= (CARD32)xkb->names->types; + if (client->swapped) { swapl((int *)desc); - } - desc+= 4; - } - if (which&XkbCompatNameMask) { - *((CARD32 *)desc)= (CARD32)xkb->names->compat; - if (client->swapped) { + } + desc+= 4; + } + if (which&XkbCompatNameMask) { + *((CARD32 *)desc)= (CARD32)xkb->names->compat; + if (client->swapped) { swapl((int *)desc); - } - desc+= 4; - } - if (which&XkbKeyTypeNamesMask) { - register CARD32 *atm= (CARD32 *)desc; - register XkbKeyTypePtr type= xkb->map->types; + } + desc+= 4; + } + if (which&XkbKeyTypeNamesMask) { + register CARD32 *atm= (CARD32 *)desc; + register XkbKeyTypePtr type= xkb->map->types; - for (i=0;imap->num_types;i++,atm++,type++) { - *atm= (CARD32)type->name; - if (client->swapped) { + for (i=0;imap->num_types;i++,atm++,type++) { + *atm= (CARD32)type->name; + if (client->swapped) { swapl(atm); - } - } - desc= (char *)atm; - } - if (which&XkbKTLevelNamesMask) { - XkbKeyTypePtr type = xkb->map->types; - register CARD32 *atm; - for (i=0;inTypes;i++,type++) { - *desc++ = type->num_levels; - } - desc+= XkbPaddedSize(rep->nTypes)-rep->nTypes; - - atm= (CARD32 *)desc; - type = xkb->map->types; - for (i=0;imap->num_types;i++,type++) { - register unsigned l; - if (type->level_names) { - for (l=0;lnum_levels;l++,atm++) { - *atm= type->level_names[l]; - if (client->swapped) { + } + } + desc= (char *)atm; + } + if (which&XkbKTLevelNamesMask && xkb->map) { + XkbKeyTypePtr type = xkb->map->types; + register CARD32 *atm; + for (i=0;inTypes;i++,type++) { + *desc++ = type->num_levels; + } + desc+= XkbPaddedSize(rep->nTypes)-rep->nTypes; + + atm= (CARD32 *)desc; + type = xkb->map->types; + for (i=0;imap->num_types;i++,type++) { + register unsigned l; + if (type->level_names) { + for (l=0;lnum_levels;l++,atm++) { + *atm= type->level_names[l]; + if (client->swapped) { swapl(atm); - } - } - desc+= type->num_levels*4; - } - } - } - if (which&XkbIndicatorNamesMask) { - desc= _XkbWriteAtoms(desc,xkb->names->indicators,XkbNumIndicators, - client->swapped); - } - if (which&XkbVirtualModNamesMask) { - desc= _XkbWriteAtoms(desc,xkb->names->vmods,XkbNumVirtualMods, - client->swapped); - } - if (which&XkbGroupNamesMask) { - desc= _XkbWriteAtoms(desc,xkb->names->groups,XkbNumKbdGroups, - client->swapped); - } - if (which&XkbKeyNamesMask) { - for (i=0;inKeys;i++,desc+= sizeof(XkbKeyNameRec)) { - *((XkbKeyNamePtr)desc)= xkb->names->keys[i+rep->firstKey]; - } - } - if (which&XkbKeyAliasesMask) { - XkbKeyAliasPtr pAl; - pAl= xkb->names->key_aliases; - for (i=0;inKeyAliases;i++,pAl++,desc+=2*XkbKeyNameLength) { - *((XkbKeyAliasPtr)desc)= *pAl; - } - } - if ((which&XkbRGNamesMask)&&(rep->nRadioGroups>0)) { - register CARD32 *atm= (CARD32 *)desc; - for (i=0;inRadioGroups;i++,atm++) { - *atm= (CARD32)xkb->names->radio_groups[i]; - if (client->swapped) { + } + } + desc+= type->num_levels*4; + } + } + } + if (which&XkbIndicatorNamesMask) { + desc= _XkbWriteAtoms(desc,xkb->names->indicators,XkbNumIndicators, + client->swapped); + } + if (which&XkbVirtualModNamesMask) { + desc= _XkbWriteAtoms(desc,xkb->names->vmods,XkbNumVirtualMods, + client->swapped); + } + if (which&XkbGroupNamesMask) { + desc= _XkbWriteAtoms(desc,xkb->names->groups,XkbNumKbdGroups, + client->swapped); + } + if (which&XkbKeyNamesMask) { + for (i=0;inKeys;i++,desc+= sizeof(XkbKeyNameRec)) { + *((XkbKeyNamePtr)desc)= xkb->names->keys[i+rep->firstKey]; + } + } + if (which&XkbKeyAliasesMask) { + XkbKeyAliasPtr pAl; + pAl= xkb->names->key_aliases; + for (i=0;inKeyAliases;i++,pAl++,desc+=2*XkbKeyNameLength) { + *((XkbKeyAliasPtr)desc)= *pAl; + } + } + if ((which&XkbRGNamesMask)&&(rep->nRadioGroups>0)) { + register CARD32 *atm= (CARD32 *)desc; + for (i=0;inRadioGroups;i++,atm++) { + *atm= (CARD32)xkb->names->radio_groups[i]; + if (client->swapped) { swapl(atm); - } - } - desc+= rep->nRadioGroups*4; + } + } + desc+= rep->nRadioGroups*4; + } } + if ((desc-start)!=(length)) { ErrorF("BOGUS LENGTH in write names, expected %d, got %ld\n", length, (unsigned long)(desc-start)); @@ -4722,7 +4670,7 @@ char * wire; if (XkbAddGeomProperty(geom,name,val)==NULL) { free(name); free(val); - return BadAlloc; + return BadAlloc; } free(name); free(val); @@ -5610,7 +5558,7 @@ char * str; wanted&= ~XkbXI_ButtonActionsMask; if ((!dev->kbdfeed)&&(!dev->leds)) wanted&= ~XkbXI_IndicatorsMask; - wanted&= ~XkbXIUnsupported; + wanted&= ~XkbXI_KeyboardsMask; nameLen= XkbSizeCountedString(dev->name); rep.type = X_Reply; @@ -5618,8 +5566,8 @@ char * str; rep.sequenceNumber = client->sequence; rep.length = nameLen/4; rep.present = wanted; - rep.supported = XkbXI_AllDeviceFeaturesMask&(~XkbXIUnsupported); - rep.unsupported = XkbXIUnsupported; + rep.supported = XkbXI_AllDeviceFeaturesMask&(~XkbXI_KeyboardsMask); + rep.unsupported = XkbXI_KeyboardsMask; rep.firstBtnWanted = rep.nBtnsWanted = 0; rep.firstBtnRtrn = rep.nBtnsRtrn = 0; if (dev->button) diff --git a/nx-X11/programs/Xserver/xkb/xkbActions.c b/nx-X11/programs/Xserver/xkb/xkbActions.c index 2bb41b928..d2dda00f4 100644 --- a/nx-X11/programs/Xserver/xkb/xkbActions.c +++ b/nx-X11/programs/Xserver/xkb/xkbActions.c @@ -996,7 +996,6 @@ _XkbFilterSwitchScreen( XkbSrvInfoPtr xkbi, return 1; } -#ifdef XFree86Server static int _XkbFilterXF86Private( XkbSrvInfoPtr xkbi, XkbFilterPtr filter, @@ -1018,7 +1017,6 @@ _XkbFilterXF86Private( XkbSrvInfoPtr xkbi, } return 1; } -#endif #ifdef XINPUT @@ -1248,12 +1246,10 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(dev); sendEvent= _XkbFilterDeviceBtn(xkbi,filter,key,&act); break; #endif -#ifdef XFree86Server case XkbSA_XFree86Private: filter = _XkbNextFreeFilter(); sendEvent= _XkbFilterXF86Private(xkbi,filter,key,&act); break; -#endif } } } diff --git a/nx-X11/programs/Xserver/xkb/xkbEvents.c b/nx-X11/programs/Xserver/xkb/xkbEvents.c index d6408a699..c7a0f9e87 100644 --- a/nx-X11/programs/Xserver/xkb/xkbEvents.c +++ b/nx-X11/programs/Xserver/xkb/xkbEvents.c @@ -207,6 +207,10 @@ int i; CARD32 changedControls; changedControls= 0; + + if (!kbd || !kbd->kbdfeed) + return 0; + if (old->enabled_ctrls!=new->enabled_ctrls) changedControls|= XkbControlsEnabledMask; if ((old->repeat_delay!=new->repeat_delay)|| diff --git a/nx-X11/programs/Xserver/xkb/xkbInit.c b/nx-X11/programs/Xserver/xkb/xkbInit.c index f39e47a87..a45906568 100644 --- a/nx-X11/programs/Xserver/xkb/xkbInit.c +++ b/nx-X11/programs/Xserver/xkb/xkbInit.c @@ -54,13 +54,6 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #define CREATE_ATOM(s) MakeAtom(s,sizeof(s)-1,1) -#if defined(ultrix) || defined(__alpha) || defined(__alpha__) -#define LED_COMPOSE 2 -#define LED_CAPS 3 -#define LED_SCROLL 4 -#define LED_NUM 5 -#define PHYS_LEDS 0x1f -#else #ifdef sun #define LED_NUM 1 #define LED_SCROLL 2 @@ -73,7 +66,6 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #define LED_SCROLL 3 #define PHYS_LEDS 0x07 #endif -#endif #define MAX_TOC 16 typedef struct _SrvXkmInfo { diff --git a/nx-X11/programs/Xserver/xkb/xkbLEDs.c b/nx-X11/programs/Xserver/xkb/xkbLEDs.c index 75e8ef3ff..2383bdd99 100644 --- a/nx-X11/programs/Xserver/xkb/xkbLEDs.c +++ b/nx-X11/programs/Xserver/xkb/xkbLEDs.c @@ -745,13 +745,13 @@ xkbExtensionDeviceNotify my_ed; changes->names.changed_indicators|= changed_names; } - ed->reason|= (XkbXI_IndicatorNamesMask&(~XkbXIUnsupported)); + ed->reason|= (XkbXI_IndicatorNamesMask&(~XkbXI_KeyboardsMask)); ed->ledClass= sli->class; ed->ledID= sli->id; ed->ledsDefined= sli->namesPresent|sli->mapsPresent; ed->ledState= sli->effectiveState; - ed->unsupported|= XkbXIUnsupported&XkbXI_IndicatorNamesMask; - ed->supported= XkbXI_AllFeaturesMask&(~XkbXIUnsupported); + ed->unsupported= XkbXI_KeyboardsMask; + ed->supported= XkbXI_AllFeaturesMask&(~XkbXI_KeyboardsMask); if (changes!=&my_changes) changes= NULL; if (ed!=&my_ed) ed= NULL; @@ -823,13 +823,13 @@ xkbExtensionDeviceNotify my_ed; XkbCheckIndicatorMaps(dev,sli,changed_maps); - ed->reason|= (XkbXI_IndicatorMapsMask&(~XkbXIUnsupported)); + ed->reason|= (XkbXI_IndicatorMapsMask&(~XkbXI_KeyboardsMask)); ed->ledClass= sli->class; ed->ledID= sli->id; ed->ledsDefined= sli->namesPresent|sli->mapsPresent; ed->ledState= sli->effectiveState; - ed->unsupported|= XkbXIUnsupported&XkbXI_IndicatorMapsMask; - ed->supported= XkbXI_AllFeaturesMask&(~XkbXIUnsupported); + ed->unsupported|= XkbXI_KeyboardsMask&XkbXI_IndicatorMapsMask; + ed->supported= XkbXI_AllFeaturesMask&(~XkbXI_KeyboardsMask); XkbUpdateLedAutoState(dev,sli,changed_maps,ed,changes,cause); @@ -904,13 +904,13 @@ Bool kb_changed; if ((kbd==dev)&&(sli->flags&XkbSLI_IsDefault)) changes->indicators.state_changes|= affected; if (affected) { - ed->reason|= (XkbXI_IndicatorStateMask&(~XkbXIUnsupported)); + ed->reason|= (XkbXI_IndicatorStateMask&(~XkbXI_KeyboardsMask)); ed->ledClass= sli->class; ed->ledID= sli->id; ed->ledsDefined= sli->namesPresent|sli->mapsPresent; ed->ledState= sli->effectiveState; - ed->unsupported|= XkbXIUnsupported&XkbXI_IndicatorStateMask; - ed->supported= XkbXI_AllFeaturesMask&(~XkbXIUnsupported); + ed->unsupported|= XkbXI_KeyboardsMask&XkbXI_IndicatorStateMask; + ed->supported= XkbXI_AllFeaturesMask&(~XkbXI_KeyboardsMask); } if (kb_changed) { diff --git a/nx-X11/programs/Xserver/xkb/xkbPrKeyEv.c b/nx-X11/programs/Xserver/xkb/xkbPrKeyEv.c index 9c13d99b5..ede23556e 100644 --- a/nx-X11/programs/Xserver/xkb/xkbPrKeyEv.c +++ b/nx-X11/programs/Xserver/xkb/xkbPrKeyEv.c @@ -149,11 +149,7 @@ unsigned ndx; 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/nx-X11/programs/Xserver/xkb/xkbUtils.c b/nx-X11/programs/Xserver/xkb/xkbUtils.c index bf88458be..c97a54bf4 100644 --- a/nx-X11/programs/Xserver/xkb/xkbUtils.c +++ b/nx-X11/programs/Xserver/xkb/xkbUtils.c @@ -711,11 +711,11 @@ unsigned char grp; grp= state->locked_group; if (grp>=ctrls->num_groups) - state->locked_group= XkbAdjustGroup(grp,ctrls); + state->locked_group= XkbAdjustGroup(XkbCharToInt(grp),ctrls); grp= state->locked_group+state->base_group+state->latched_group; if (grp>=ctrls->num_groups) - state->group= XkbAdjustGroup(grp,ctrls); + state->group= XkbAdjustGroup(XkbCharToInt(grp),ctrls); else state->group= grp; XkbComputeCompatState(xkbi); return; diff --git a/nx-X11/programs/Xserver/xkb/xkbfmisc.c b/nx-X11/programs/Xserver/xkb/xkbfmisc.c index d2d4a5d43..823bb7479 100644 --- a/nx-X11/programs/Xserver/xkb/xkbfmisc.c +++ b/nx-X11/programs/Xserver/xkb/xkbfmisc.c @@ -46,18 +46,185 @@ #include "xkbgeom.h" #include "xkb.h" +unsigned +_XkbKSCheckCase(KeySym ks) +{ +unsigned set,rtrn; + + set= (ks & (~0xff)) >> 8; + rtrn= 0; + switch (set) { + case 0: /* latin 1 */ + 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 (ks==XK_oe) { + rtrn|= _XkbKSLower; + } + break; + } + return rtrn; +} + +/***===================================================================***/ + +Bool +XkbLookupGroupAndLevel( XkbDescPtr xkb, + int key, + int * mods_inout, + int * grp_inout, + int * lvl_rtrn) +{ +int nG,eG; + + if ((!xkb)||(!XkbKeycodeInRange(xkb,key))||(!grp_inout)) + return False; + + nG= XkbKeyNumGroups(xkb,key); + eG= *grp_inout; + + if ( nG==0 ) { + *grp_inout= 0; + if (lvl_rtrn!=NULL) + *lvl_rtrn= 0; + return False; + } + else if ( nG==1 ) { + eG= 0; + } + else if ( eG>=nG ) { + unsigned gI= XkbKeyGroupInfo(xkb,key); + switch (XkbOutOfRangeGroupAction(gI)) { + default: + eG %= nG; + break; + case XkbClampIntoRange: + eG = nG-1; + break; + case XkbRedirectIntoRange: + eG = XkbOutOfRangeGroupNumber(gI); + if (eG>=nG) + eG= 0; + break; + } + } + *grp_inout= eG; + if (mods_inout!=NULL) { + XkbKeyTypePtr type; + int preserve; + + type = XkbKeyKeyType(xkb,key,eG); + if (lvl_rtrn!=NULL) + *lvl_rtrn= 0; + preserve= 0; + if (type->map) { /* find the shift level */ + register int i; + register XkbKTMapEntryPtr entry; + for (i=0,entry=type->map;imap_count;i++,entry++) { + if ((entry->active)&& + (((*mods_inout)&type->mods.mask)==entry->mods.mask)){ + if (lvl_rtrn!=NULL) + *lvl_rtrn= entry->level; + if (type->preserve) + preserve= type->preserve[i].mask; + break; + } + } + } + (*mods_inout)&= ~(type->mods.mask&(~preserve)); + } + return True; +} + /***===================================================================***/ static Bool XkbWriteSectionFromName(FILE *file,char *sectionName,char *name) { fprintf(file," xkb_%-20s { include \"%s\" };\n",sectionName,name); - ErrorF(" xkb_%-20s { include \"%s\" };\n",sectionName,name); return True; } -#define NEED_DESC(n) ((!n)||((n)[0]=='+')||((n)[0]=='|')||(strchr((n),'%'))) -#define COMPLETE(n) ((n)&&(!NEED_DESC(n))) +#define NEED_DESC(n) ((!n)||((n)[0]=='+')||((n)[0]=='|')||(strchr((n),'%'))) +#define COMPLETE(n) ((n)&&(!NEED_DESC(n))) + +/* ARGSUSED */ +static void +_AddIncl( FILE * file, + XkbFileInfo * result, + Bool topLevel, + Bool showImplicit, + int index, + void * priv) +{ + if ((priv)&&(strcmp((char *)priv,"%")!=0)) + fprintf(file," include \"%s\"\n",(char *)priv); + return; +} + Bool XkbWriteXKBKeymapForNames( FILE * file, XkbComponentNamesPtr names, @@ -66,29 +233,230 @@ XkbWriteXKBKeymapForNames( FILE * file, unsigned want, unsigned need) { - if (!names || (!names->keycodes && !names->types && !names->compat && - !names->symbols && !names->geometry)) - return False; - - fprintf(file, "xkb_keymap \"%s\" {\n", names->keymap ? names->keymap : - "default"); - - if (names->keycodes) - XkbWriteSectionFromName(file, "keycodes", names->keycodes); - if (names->types) - XkbWriteSectionFromName(file, "types", names->types); - if (names->compat) - XkbWriteSectionFromName(file, "compatibility", names->compat); - if (names->symbols) - XkbWriteSectionFromName(file, "symbols", names->symbols); - if (names->geometry) - XkbWriteSectionFromName(file, "geometry", names->geometry); - - fprintf(file,"};\n"); +char * name; +const char * tmp; +unsigned complete; +XkbNamesPtr old_names; +int multi_section; +unsigned wantNames,wantConfig,wantDflts; +XkbFileInfo finfo; + + bzero(&finfo,sizeof(XkbFileInfo)); + + complete= 0; + if ((name=names->keymap)==NULL) name= "default"; + if (COMPLETE(names->keycodes)) complete|= XkmKeyNamesMask; + if (COMPLETE(names->types)) complete|= XkmTypesMask; + if (COMPLETE(names->compat)) complete|= XkmCompatMapMask; + if (COMPLETE(names->symbols)) complete|= XkmSymbolsMask; + if (COMPLETE(names->geometry)) complete|= XkmGeometryMask; + want|= (complete|need); + if (want&XkmSymbolsMask) + want|= XkmKeyNamesMask|XkmTypesMask; + + if (want==0) + return False; + + if (xkb!=NULL) { + old_names= xkb->names; + finfo.type= 0; + finfo.defined= 0; + finfo.xkb= xkb; + if (!XkbDetermineFileType(&finfo,XkbXKBFile,NULL)) + return False; + } + else old_names= NULL; + wantConfig= want&(~complete); + if (xkb!=NULL) { + if (wantConfig&XkmTypesMask) { + if ((!xkb->map) || (xkb->map->num_typescompat) || (xkb->compat->num_si<1)) + wantConfig&= ~XkmCompatMapMask; + } + if (wantConfig&XkmSymbolsMask) { + if ((!xkb->map) || (!xkb->map->key_sym_map)) + wantConfig&= ~XkmSymbolsMask; + } + if (wantConfig&XkmIndicatorsMask) { + if (!xkb->indicators) + wantConfig&= ~XkmIndicatorsMask; + } + if (wantConfig&XkmKeyNamesMask) { + if ((!xkb->names)||(!xkb->names->keys)) + wantConfig&= ~XkmKeyNamesMask; + } + if ((wantConfig&XkmGeometryMask)&&(!xkb->geom)) + wantConfig&= ~XkmGeometryMask; + } + else { + wantConfig= 0; + } + complete|= wantConfig; + + wantDflts= 0; + wantNames= want&(~complete); + if ((xkb!=NULL) && (old_names!=NULL)) { + if (wantNames&XkmTypesMask) { + if (old_names->types!=None) { + tmp= NameForAtom(old_names->types); + names->types= Xstrdup(tmp); + } + else { + wantDflts|= XkmTypesMask; + } + complete|= XkmTypesMask; + } + if (wantNames&XkmCompatMapMask) { + if (old_names->compat!=None) { + tmp= NameForAtom(old_names->compat); + names->compat= Xstrdup(tmp); + } + else wantDflts|= XkmCompatMapMask; + complete|= XkmCompatMapMask; + } + if (wantNames&XkmSymbolsMask) { + if (old_names->symbols==None) + return False; + tmp= NameForAtom(old_names->symbols); + names->symbols= Xstrdup(tmp); + complete|= XkmSymbolsMask; + } + if (wantNames&XkmKeyNamesMask) { + if (old_names->keycodes!=None) { + tmp= NameForAtom(old_names->keycodes); + names->keycodes= Xstrdup(tmp); + } + else wantDflts|= XkmKeyNamesMask; + complete|= XkmKeyNamesMask; + } + if (wantNames&XkmGeometryMask) { + if (old_names->geometry==None) + return False; + tmp= NameForAtom(old_names->geometry); + names->geometry= Xstrdup(tmp); + complete|= XkmGeometryMask; + wantNames&= ~XkmGeometryMask; + } + } + if (complete&XkmCompatMapMask) + complete|= XkmIndicatorsMask|XkmVirtualModsMask; + else if (complete&(XkmSymbolsMask|XkmTypesMask)) + complete|= XkmVirtualModsMask; + if (need & (~complete)) + return False; + if ((complete&XkmSymbolsMask)&&((XkmKeyNamesMask|XkmTypesMask)&(~complete))) + return False; + + multi_section= 1; + if (((complete&XkmKeymapRequired)==XkmKeymapRequired)&& + ((complete&(~XkmKeymapLegal))==0)) { + fprintf(file,"xkb_keymap \"%s\" {\n",name); + } + else if (((complete&XkmSemanticsRequired)==XkmSemanticsRequired)&& + ((complete&(~XkmSemanticsLegal))==0)) { + fprintf(file,"xkb_semantics \"%s\" {\n",name); + } + else if (((complete&XkmLayoutRequired)==XkmLayoutRequired)&& + ((complete&(~XkmLayoutLegal))==0)) { + fprintf(file,"xkb_layout \"%s\" {\n",name); + } + else if (XkmSingleSection(complete&(~XkmVirtualModsMask))) { + multi_section= 0; + } + else { + return False; + } + + wantNames= complete&(~(wantConfig|wantDflts)); + name= names->keycodes; + if (wantConfig&XkmKeyNamesMask) + XkbWriteXKBKeycodes(file,&finfo,False,False,_AddIncl,name); + else if (wantDflts&XkmKeyNamesMask) + fprintf(stderr,"Default symbols not implemented yet!\n"); + else if (wantNames&XkmKeyNamesMask) + XkbWriteSectionFromName(file,"keycodes",name); + + name= names->types; + if (wantConfig&XkmTypesMask) + XkbWriteXKBKeyTypes(file,&finfo,False,False,_AddIncl,name); + else if (wantDflts&XkmTypesMask) + fprintf(stderr,"Default types not implemented yet!\n"); + else if (wantNames&XkmTypesMask) + XkbWriteSectionFromName(file,"types",name); + + name= names->compat; + if (wantConfig&XkmCompatMapMask) + XkbWriteXKBCompatMap(file,&finfo,False,False,_AddIncl,name); + else if (wantDflts&XkmCompatMapMask) + fprintf(stderr,"Default interps not implemented yet!\n"); + else if (wantNames&XkmCompatMapMask) + XkbWriteSectionFromName(file,"compatibility",name); + + name= names->symbols; + if (wantConfig&XkmSymbolsMask) + XkbWriteXKBSymbols(file,&finfo,False,False,_AddIncl,name); + else if (wantNames&XkmSymbolsMask) + XkbWriteSectionFromName(file,"symbols",name); + + name= names->geometry; + if (wantConfig&XkmGeometryMask) + XkbWriteXKBGeometry(file,&finfo,False,False,_AddIncl,name); + else if (wantNames&XkmGeometryMask) + XkbWriteSectionFromName(file,"geometry",name); + + if (multi_section) + fprintf(file,"};\n"); return True; } +/***====================================================================***/ + +/*ARGSUSED*/ +Status +XkbMergeFile(XkbDescPtr xkb,XkbFileInfo finfo) +{ + return BadImplementation; +} + +/***====================================================================***/ + +int +XkbFindKeycodeByName(XkbDescPtr xkb,char *name,Bool use_aliases) +{ +register int i; + + if ((!xkb)||(!xkb->names)||(!xkb->names->keys)) + return 0; + for (i=xkb->min_key_code;i<=xkb->max_key_code;i++) { + if (strncmp(xkb->names->keys[i].name,name,XkbKeyNameLength)==0) + return i; + } + if (!use_aliases) + return 0; + if (xkb->geom && xkb->geom->key_aliases) { + XkbKeyAliasPtr a; + a= xkb->geom->key_aliases; + for (i=0;igeom->num_key_aliases;i++,a++) { + if (strncmp(name,a->alias,XkbKeyNameLength)==0) + return XkbFindKeycodeByName(xkb,a->real,False); + } + } + if (xkb->names && xkb->names->key_aliases) { + XkbKeyAliasPtr a; + a= xkb->names->key_aliases; + for (i=0;inames->num_key_aliases;i++,a++) { + if (strncmp(name,a->alias,XkbKeyNameLength)==0) + return XkbFindKeycodeByName(xkb,a->real,False); + } + } + return 0; +} + + unsigned XkbConvertGetByNameComponents(Bool toXkm,unsigned orig) { @@ -115,6 +483,34 @@ unsigned rtrn; return rtrn; } +unsigned +XkbConvertXkbComponents(Bool toXkm,unsigned orig) +{ +unsigned rtrn; + + rtrn= 0; + if (toXkm) { + if (orig&XkbClientMapMask) rtrn|= XkmTypesMask|XkmSymbolsMask; + if (orig&XkbServerMapMask) rtrn|= XkmTypesMask|XkmSymbolsMask; + if (orig&XkbCompatMapMask) rtrn|= XkmCompatMapMask; + if (orig&XkbIndicatorMapMask) rtrn|= XkmIndicatorsMask; + if (orig&XkbNamesMask) rtrn|= XkmKeyNamesMask; + if (orig&XkbGeometryMask) rtrn|= XkmGeometryMask; + } + else { + if (orig!=0) rtrn|= XkbNamesMask; + if (orig&XkmTypesMask) rtrn|= XkbClientMapMask; + if (orig&XkmCompatMapMask) + rtrn|= XkbCompatMapMask|XkbIndicatorMapMask; + if (orig&XkmSymbolsMask) rtrn|=XkbClientMapMask|XkbServerMapMask; + if (orig&XkmIndicatorsMask) rtrn|= XkbIndicatorMapMask; + if (orig&XkmKeyNamesMask) + rtrn|= XkbNamesMask|XkbIndicatorMapMask; + if (orig&XkmGeometryMask) rtrn|= XkbGeometryMask; + } + return rtrn; +} + Bool XkbDetermineFileType(XkbFileInfoPtr finfo,int format,int *opts_missing) { @@ -245,19 +641,3 @@ XkbNameMatchesPattern(char *name,char *ptrn) /* if we get here, the pattern is exhausted (-:just like me:-) */ return (name[0]=='\0'); } - -#ifdef NEED_STRCASECMP -_X_HIDDEN int -_XkbStrCaseCmp(char *str1,char *str2) -{ - const u_char *us1 = (const u_char *)str1, *us2 = (const u_char *)str2; - - while (tolower(*us1) == tolower(*us2)) { - if (*us1++ == '\0') - return (0); - us2++; - } - - return (tolower(*us1) - tolower(*us2)); -} -#endif diff --git a/nx-X11/programs/Xserver/xkb/xkbout.c b/nx-X11/programs/Xserver/xkb/xkbout.c new file mode 100644 index 000000000..ae821c909 --- /dev/null +++ b/nx-X11/programs/Xserver/xkb/xkbout.c @@ -0,0 +1,1047 @@ +/************************************************************ + Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc. + + Permission to use, copy, modify, and distribute this + software and its documentation for any purpose and without + fee is hereby granted, provided that the above copyright + notice appear in all copies and that both that copyright + notice and this permission notice appear in supporting + documentation, and that the name of Silicon Graphics not be + used in advertising or publicity pertaining to distribution + of the software without specific prior written permission. + Silicon Graphics makes no representation about the suitability + of this software for any purpose. It is provided "as is" + without any express or implied warranty. + + SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS + SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON + GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE + OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH + THE USE OR PERFORMANCE OF THIS SOFTWARE. + + ********************************************************/ + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#include +#include +#include +#include + +#include +#include +#include +#include "misc.h" +#include "inputstr.h" +#include "dix.h" +#include "xkbstr.h" +#include + +#include "xkbgeom.h" +#include + +#define VMOD_HIDE_VALUE 0 +#define VMOD_SHOW_VALUE 1 +#define VMOD_COMMENT_VALUE 2 + +static Bool +WriteXKBVModDecl(FILE *file,Display *dpy,XkbDescPtr xkb,int showValue) +{ +register int i,nMods; +Atom * vmodNames; + + if (xkb==NULL) + return False; + if (xkb->names!=NULL) + vmodNames= xkb->names->vmods; + else vmodNames= NULL; + + for (i=nMods=0;iserver)&&(xkb->server->vmods[i]!=XkbNoModifierMask)) { + if (showValue==VMOD_COMMENT_VALUE) { + fprintf(file,"/* = %s */", + XkbModMaskText(xkb->server->vmods[i],XkbXKBFile)); + } + else { + fprintf(file,"= %s", + XkbModMaskText(xkb->server->vmods[i],XkbXKBFile)); + } + } + nMods++; + } + } + if (nMods>0) + fprintf(file,";\n\n"); + return True; +} + +/***====================================================================***/ + +static Bool +WriteXKBAction(FILE *file,XkbFileInfo *result,XkbAnyAction *action) +{ +XkbDescPtr xkb; +Display * dpy; + + xkb= result->xkb; + dpy= xkb->dpy; + fprintf(file,"%s",XkbActionText(dpy,xkb,(XkbAction *)action,XkbXKBFile)); + return True; +} + +/***====================================================================***/ + +Bool +XkbWriteXKBKeycodes( FILE * file, + XkbFileInfo * result, + Bool topLevel, + Bool showImplicit, + XkbFileAddOnFunc addOn, + void * priv) +{ +Atom kcName; +register unsigned i; +XkbDescPtr xkb; +Display * dpy; +char * alternate; + + xkb= result->xkb; + dpy= xkb->dpy; + if ((!xkb)||(!xkb->names)||(!xkb->names->keys)) { + _XkbLibError(_XkbErrMissingNames,"XkbWriteXKBKeycodes",0); + return False; + } + kcName= xkb->names->keycodes; + if (kcName!=None) + fprintf(file,"xkb_keycodes \"%s\" {\n", + XkbAtomText(dpy,kcName,XkbXKBFile)); + else fprintf(file,"xkb_keycodes {\n"); + fprintf(file," minimum = %d;\n",xkb->min_key_code); + fprintf(file," maximum = %d;\n",xkb->max_key_code); + for (i=xkb->min_key_code;i<=xkb->max_key_code;i++) { + if (xkb->names->keys[i].name[0]!='\0') { + if (XkbFindKeycodeByName(xkb,xkb->names->keys[i].name,True)!=i) + alternate= "alternate "; + else alternate= ""; + fprintf(file," %s%6s = %d;\n",alternate, + XkbKeyNameText(xkb->names->keys[i].name,XkbXKBFile), + i); + } + } + if (xkb->indicators!=NULL) { + for (i=0;iindicators->phys_indicators&(1<names->indicators[i]!=None) { + fprintf(file,"%sindicator %d = \"%s\";\n",type,i+1, + XkbAtomText(dpy,xkb->names->indicators[i],XkbXKBFile)); + } + } + } + if (xkb->names->key_aliases!=NULL) { + XkbKeyAliasPtr pAl; + pAl= xkb->names->key_aliases; + for (i=0;inames->num_key_aliases;i++,pAl++) { + fprintf(file," alias %6s = %6s;\n", + XkbKeyNameText(pAl->alias,XkbXKBFile), + XkbKeyNameText(pAl->real,XkbXKBFile)); + } + } + if (addOn) + (*addOn)(file,result,topLevel,showImplicit,XkmKeyNamesIndex,priv); + fprintf(file,"};\n\n"); + return True; +} + +Bool +XkbWriteXKBKeyTypes( FILE * file, + XkbFileInfo * result, + Bool topLevel, + Bool showImplicit, + XkbFileAddOnFunc addOn, + void * priv) +{ +Display * dpy; +register unsigned i,n; +XkbKeyTypePtr type; +XkbKTMapEntryPtr entry; +XkbDescPtr xkb; + + xkb= result->xkb; + dpy= xkb->dpy; + if ((!xkb)||(!xkb->map)||(!xkb->map->types)) { + _XkbLibError(_XkbErrMissingTypes,"XkbWriteXKBKeyTypes",0); + return False; + } + if (xkb->map->num_typesnames==NULL)||(xkb->names->types==None)) + fprintf(file,"xkb_types {\n\n"); + else fprintf(file,"xkb_types \"%s\" {\n\n", + XkbAtomText(dpy,xkb->names->types,XkbXKBFile)); + WriteXKBVModDecl(file,dpy,xkb, + (showImplicit?VMOD_COMMENT_VALUE:VMOD_HIDE_VALUE)); + + type= xkb->map->types; + for (i=0;imap->num_types;i++,type++) { + fprintf(file," type \"%s\" {\n", + XkbAtomText(dpy,type->name,XkbXKBFile)); + fprintf(file," modifiers= %s;\n", + XkbVModMaskText(dpy,xkb,type->mods.real_mods,type->mods.vmods, + XkbXKBFile)); + entry= type->map; + for (n=0;nmap_count;n++,entry++) { + char *str; + str=XkbVModMaskText(dpy,xkb,entry->mods.real_mods,entry->mods.vmods, + XkbXKBFile); + fprintf(file," map[%s]= Level%d;\n",str,entry->level+1); + if ((type->preserve)&&((type->preserve[n].real_mods)|| + (type->preserve[n].vmods))) { + fprintf(file," preserve[%s]= ",str); + fprintf(file,"%s;\n",XkbVModMaskText(dpy,xkb, + type->preserve[n].real_mods, + type->preserve[n].vmods, + XkbXKBFile)); + } + } + if (type->level_names!=NULL) { + Atom *name= type->level_names; + for (n=0;nnum_levels;n++,name++) { + if ((*name)==None) + continue; + fprintf(file," level_name[Level%d]= \"%s\";\n",n+1, + XkbAtomText(dpy,*name,XkbXKBFile)); + } + } + fprintf(file," };\n"); + } + if (addOn) + (*addOn)(file,result,topLevel,showImplicit,XkmTypesIndex,priv); + fprintf(file,"};\n\n"); + return True; +} + +static Bool +WriteXKBIndicatorMap( FILE * file, + XkbFileInfo * result, + Atom name, + XkbIndicatorMapPtr led, + XkbFileAddOnFunc addOn, + void * priv) +{ +XkbDescPtr xkb; + + xkb= result->xkb; + fprintf(file," indicator \"%s\" {\n",NameForAtom(name)); + if (led->flags&XkbIM_NoExplicit) + fprintf(file," !allowExplicit;\n"); + if (led->flags&XkbIM_LEDDrivesKB) + fprintf(file," indicatorDrivesKeyboard;\n"); + if (led->which_groups!=0) { + if (led->which_groups!=XkbIM_UseEffective) { + fprintf(file," whichGroupState= %s;\n", + XkbIMWhichStateMaskText(led->which_groups,XkbXKBFile)); + } + fprintf(file," groups= 0x%02x;\n",led->groups); + } + if (led->which_mods!=0) { + if (led->which_mods!=XkbIM_UseEffective) { + fprintf(file," whichModState= %s;\n", + XkbIMWhichStateMaskText(led->which_mods,XkbXKBFile)); + } + fprintf(file," modifiers= %s;\n", + XkbVModMaskText(xkb->dpy,xkb, + led->mods.real_mods,led->mods.vmods, + XkbXKBFile)); + } + if (led->ctrls!=0) { + fprintf(file," controls= %s;\n", + XkbControlsMaskText(led->ctrls,XkbXKBFile)); + } + if (addOn) + (*addOn)(file,result,False,True,XkmIndicatorsIndex,priv); + fprintf(file," };\n"); + return True; +} + +Bool +XkbWriteXKBCompatMap( FILE * file, + XkbFileInfo * result, + Bool topLevel, + Bool showImplicit, + XkbFileAddOnFunc addOn, + void * priv) +{ +Display * dpy; +register unsigned i; +XkbSymInterpretPtr interp; +XkbDescPtr xkb; + + xkb= result->xkb; + dpy= xkb->dpy; + if ((!xkb)||(!xkb->compat)||(!xkb->compat->sym_interpret)) { + _XkbLibError(_XkbErrMissingCompatMap,"XkbWriteXKBCompatMap",0); + return False; + } + if ((xkb->names==NULL)||(xkb->names->compat==None)) + fprintf(file,"xkb_compatibility {\n\n"); + else fprintf(file,"xkb_compatibility \"%s\" {\n\n", + XkbAtomText(dpy,xkb->names->compat,XkbXKBFile)); + WriteXKBVModDecl(file,dpy,xkb, + (showImplicit?VMOD_COMMENT_VALUE:VMOD_HIDE_VALUE)); + + fprintf(file," interpret.useModMapMods= AnyLevel;\n"); + fprintf(file," interpret.repeat= False;\n"); + fprintf(file," interpret.locking= False;\n"); + interp= xkb->compat->sym_interpret; + for (i=0;icompat->num_si;i++,interp++) { + fprintf(file," interpret %s+%s(%s) {\n", + ((interp->sym==NoSymbol)?"Any": + XkbKeysymText(interp->sym,XkbXKBFile)), + XkbSIMatchText(interp->match,XkbXKBFile), + XkbModMaskText(interp->mods,XkbXKBFile)); + if (interp->virtual_mod!=XkbNoModifier) { + fprintf(file," virtualModifier= %s;\n", + XkbVModIndexText(dpy,xkb,interp->virtual_mod,XkbXKBFile)); + } + if (interp->match&XkbSI_LevelOneOnly) + fprintf(file," useModMapMods=level1;\n"); + if (interp->flags&XkbSI_LockingKey) + fprintf(file," locking= True;\n"); + if (interp->flags&XkbSI_AutoRepeat) + fprintf(file," repeat= True;\n"); + fprintf(file," action= "); + WriteXKBAction(file,result,&interp->act); + fprintf(file,";\n"); + fprintf(file," };\n"); + } + for (i=0;icompat->groups[i]; + if ((gc->real_mods==0)&&(gc->vmods==0)) + continue; + fprintf(file," group %d = %s;\n",i+1,XkbVModMaskText(xkb->dpy,xkb, + gc->real_mods,gc->vmods, + XkbXKBFile)); + } + if (xkb->indicators) { + for (i=0;iindicators->maps[i]; + if ((map->flags!=0)||(map->which_groups!=0)||(map->groups!=0)|| + (map->which_mods!=0)|| + (map->mods.real_mods!=0)||(map->mods.vmods!=0)|| + (map->ctrls!=0)) { + WriteXKBIndicatorMap(file,result,xkb->names->indicators[i],map, + addOn,priv); + } + } + } + if (addOn) + (*addOn)(file,result,topLevel,showImplicit,XkmCompatMapIndex,priv); + fprintf(file,"};\n\n"); + return True; +} + +Bool +XkbWriteXKBSymbols( FILE * file, + XkbFileInfo * result, + Bool topLevel, + Bool showImplicit, + XkbFileAddOnFunc addOn, + void * priv) +{ +Display * dpy; +register unsigned i,tmp; +XkbDescPtr xkb; +XkbClientMapPtr map; +XkbServerMapPtr srv; +Bool showActions; + + xkb= result->xkb; + map= xkb->map; + srv= xkb->server; + dpy= xkb->dpy; + if ((!xkb)||(!map)||(!map->syms)||(!map->key_sym_map)) { + _XkbLibError(_XkbErrMissingSymbols,"XkbWriteXKBSymbols",0); + return False; + } + if ((!xkb->names)||(!xkb->names->keys)) { + _XkbLibError(_XkbErrMissingNames,"XkbWriteXKBSymbols",0); + return False; + } + if ((xkb->names==NULL)||(xkb->names->symbols==None)) + fprintf(file,"xkb_symbols {\n\n"); + else fprintf(file,"xkb_symbols \"%s\" {\n\n", + XkbAtomText(dpy,xkb->names->symbols,XkbXKBFile)); + for (tmp=i=0;inames->groups[i]!=None) { + fprintf(file," name[group%d]=\"%s\";\n",i+1, + XkbAtomText(dpy,xkb->names->groups[i],XkbXKBFile)); + tmp++; + } + } + if (tmp>0) + fprintf(file,"\n"); + for (i=xkb->min_key_code;i<=xkb->max_key_code;i++) { + Bool simple; + if ((int)XkbKeyNumSyms(xkb,i)<1) + continue; + if (XkbFindKeycodeByName(xkb,xkb->names->keys[i].name,True)!=i) + continue; + simple= True; + fprintf(file," key %6s {", + XkbKeyNameText(xkb->names->keys[i].name,XkbXKBFile)); + if (srv->explicit) { + if (((srv->explicit[i]&XkbExplicitKeyTypesMask)!=0)|| + (showImplicit)) { + int typeNdx,g; + Bool multi; + char * comment=" "; + + if ((srv->explicit[i]&XkbExplicitKeyTypesMask)==0) + comment= "//"; + multi= False; + typeNdx= XkbKeyKeyTypeIndex(xkb,i,0); + for (g=1;(gexplicit[i]&(1<types[typeNdx].name, + XkbXKBFile)); + } + else if (showImplicit) { + fprintf(file,"\n// type[group%d]= \"%s\",",g+1, + XkbAtomText(dpy,map->types[typeNdx].name, + XkbXKBFile)); + } + } + } + else { + fprintf(file,"\n%s type= \"%s\",",comment, + XkbAtomText(dpy,map->types[typeNdx].name, + XkbXKBFile)); + } + simple= False; + } + if (((srv->explicit[i]&XkbExplicitAutoRepeatMask)!=0)&& + (xkb->ctrls!=NULL)) { + if (xkb->ctrls->per_key_repeat[i/8]&(1<<(i%8))) + fprintf(file,"\n repeat= Yes,"); + else fprintf(file,"\n repeat= No,"); + simple= False; + } + if ((xkb->server!=NULL)&&(xkb->server->vmodmap!=NULL)&& + (xkb->server->vmodmap[i]!=0)) { + if ((srv->explicit[i]&XkbExplicitVModMapMask)!=0) { + fprintf(file,"\n virtualMods= %s,", + XkbVModMaskText(dpy,xkb,0, + xkb->server->vmodmap[i], + XkbXKBFile)); + } + else if (showImplicit) { + fprintf(file,"\n// virtualMods= %s,", + XkbVModMaskText(dpy,xkb,0, + xkb->server->vmodmap[i], + XkbXKBFile)); + } + } + } + switch (XkbOutOfRangeGroupAction(XkbKeyGroupInfo(xkb,i))) { + case XkbClampIntoRange: + fprintf(file,"\n groupsClamp,"); + break; + case XkbRedirectIntoRange: + fprintf(file,"\n groupsRedirect= Group%d,", + XkbOutOfRangeGroupNumber(XkbKeyGroupInfo(xkb,i))+1); + break; + } + if (srv->behaviors!=NULL) { + unsigned type; + type= srv->behaviors[i].type&XkbKB_OpMask; + + if (type!=XkbKB_Default) { + simple= False; + fprintf(file,"\n %s,", + XkbBehaviorText(xkb,&srv->behaviors[i],XkbXKBFile)); + } + } + if ((srv->explicit==NULL) || showImplicit || + ((srv->explicit[i]&XkbExplicitInterpretMask)!=0)) + showActions= XkbKeyHasActions(xkb,i); + else showActions= False; + + if (((unsigned)XkbKeyNumGroups(xkb,i)>1)||showActions) + simple= False; + if (simple) { + KeySym *syms; + unsigned s; + + syms= XkbKeySymsPtr(xkb,i); + fprintf(file," [ "); + for (s=0;smodmap) { + for (i=xkb->min_key_code;i<=xkb->max_key_code;i++) { + if (map->modmap[i]!=0) { + register int n,bit; + for (bit=1,n=0;nmodmap[i]&bit) { + char buf[5]; + memcpy(buf,xkb->names->keys[i].name,4); + buf[4]= '\0'; + fprintf(file," modifier_map %s { <%s> };\n", + XkbModIndexText(n,XkbXKBFile),buf); + } + } + } + } + } + if (addOn) + (*addOn)(file,result,topLevel,showImplicit,XkmSymbolsIndex,priv); + fprintf(file,"};\n\n"); + return True; +} + +static Bool +WriteXKBOutline( FILE * file, + XkbShapePtr shape, + XkbOutlinePtr outline, + int lastRadius, + int first, + int indent) +{ +register int i; +XkbPointPtr pt; +char * iStr; + + fprintf(file,"%s",iStr= XkbIndentText(first)); + if (first!=indent) + iStr= XkbIndentText(indent); + if (outline->corner_radius!=lastRadius) { + fprintf(file,"corner= %s,", + XkbGeomFPText(outline->corner_radius,XkbMessage)); + if (shape!=NULL) { + fprintf(file,"\n%s",iStr); + } + } + if (shape) { + if (outline==shape->approx) + fprintf(file,"approx= "); + else if (outline==shape->primary) + fprintf(file,"primary= "); + } + fprintf(file,"{"); + for (pt=outline->points,i=0;inum_points;i++,pt++) { + if (i==0) fprintf(file," "); + else if ((i%4)==0) fprintf(file,",\n%s ",iStr); + else fprintf(file,", "); + fprintf(file,"[ %3s, %3s ]",XkbGeomFPText(pt->x,XkbXKBFile), + XkbGeomFPText(pt->y,XkbXKBFile)); + } + fprintf(file," }"); + return True; +} + +static Bool +WriteXKBDoodad( FILE * file, + Display * dpy, + unsigned indent, + XkbGeometryPtr geom, + XkbDoodadPtr doodad) +{ +register char * i_str; +XkbShapePtr shape; +XkbColorPtr color; + + i_str= XkbIndentText(indent); + fprintf(file,"%s%s \"%s\" {\n",i_str, + XkbDoodadTypeText(doodad->any.type,XkbMessage), + XkbAtomText(dpy,doodad->any.name,XkbMessage)); + fprintf(file,"%s top= %s;\n",i_str, + XkbGeomFPText(doodad->any.top,XkbXKBFile)); + fprintf(file,"%s left= %s;\n",i_str, + XkbGeomFPText(doodad->any.left,XkbXKBFile)); + fprintf(file,"%s priority= %d;\n",i_str,doodad->any.priority); + switch (doodad->any.type) { + case XkbOutlineDoodad: + case XkbSolidDoodad: + if (doodad->shape.angle!=0) { + fprintf(file,"%s angle= %s;\n",i_str, + XkbGeomFPText(doodad->shape.angle,XkbXKBFile)); + } + if (doodad->shape.color_ndx!=0) { + fprintf(file,"%s color= \"%s\";\n",i_str, + XkbShapeDoodadColor(geom,&doodad->shape)->spec); + } + shape= XkbShapeDoodadShape(geom,&doodad->shape); + fprintf(file,"%s shape= \"%s\";\n",i_str, + XkbAtomText(dpy,shape->name,XkbXKBFile)); + break; + case XkbTextDoodad: + if (doodad->text.angle!=0) { + fprintf(file,"%s angle= %s;\n",i_str, + XkbGeomFPText(doodad->text.angle,XkbXKBFile)); + } + if (doodad->text.width!=0) { + fprintf(file,"%s width= %s;\n",i_str, + XkbGeomFPText(doodad->text.width,XkbXKBFile)); + + } + if (doodad->text.height!=0) { + fprintf(file,"%s height= %s;\n",i_str, + XkbGeomFPText(doodad->text.height,XkbXKBFile)); + + } + if (doodad->text.color_ndx!=0) { + color= XkbTextDoodadColor(geom,&doodad->text); + fprintf(file,"%s color= \"%s\";\n",i_str, + XkbStringText(color->spec,XkbXKBFile)); + } + fprintf(file,"%s XFont= \"%s\";\n",i_str, + XkbStringText(doodad->text.font,XkbXKBFile)); + fprintf(file,"%s text= \"%s\";\n",i_str, + XkbStringText(doodad->text.text,XkbXKBFile)); + break; + case XkbIndicatorDoodad: + shape= XkbIndicatorDoodadShape(geom,&doodad->indicator); + color= XkbIndicatorDoodadOnColor(geom,&doodad->indicator); + fprintf(file,"%s onColor= \"%s\";\n",i_str, + XkbStringText(color->spec,XkbXKBFile)); + color= XkbIndicatorDoodadOffColor(geom,&doodad->indicator); + fprintf(file,"%s offColor= \"%s\";\n",i_str, + XkbStringText(color->spec,XkbXKBFile)); + fprintf(file,"%s shape= \"%s\";\n",i_str, + XkbAtomText(dpy,shape->name,XkbXKBFile)); + break; + case XkbLogoDoodad: + fprintf(file,"%s logoName= \"%s\";\n",i_str, + XkbStringText(doodad->logo.logo_name,XkbXKBFile)); + if (doodad->shape.angle!=0) { + fprintf(file,"%s angle= %s;\n",i_str, + XkbGeomFPText(doodad->logo.angle,XkbXKBFile)); + } + if (doodad->shape.color_ndx!=0) { + fprintf(file,"%s color= \"%s\";\n",i_str, + XkbLogoDoodadColor(geom,&doodad->logo)->spec); + } + shape= XkbLogoDoodadShape(geom,&doodad->logo); + fprintf(file,"%s shape= \"%s\";\n",i_str, + XkbAtomText(dpy,shape->name,XkbXKBFile)); + break; + } + fprintf(file,"%s};\n",i_str); + return True; +} + +/*ARGSUSED*/ +static Bool +WriteXKBOverlay( FILE * file, + Display * dpy, + unsigned indent, + XkbGeometryPtr geom, + XkbOverlayPtr ol) +{ +register char * i_str; +int r,k,nOut; +XkbOverlayRowPtr row; +XkbOverlayKeyPtr key; + + i_str= XkbIndentText(indent); + if (ol->name!=None) { + fprintf(file,"%soverlay \"%s\" {\n",i_str, + XkbAtomText(dpy,ol->name,XkbMessage)); + } + else fprintf(file,"%soverlay {\n",i_str); + for (nOut=r=0,row=ol->rows;rnum_rows;r++,row++) { + for (k=0,key=row->keys;knum_keys;k++,key++) { + char *over,*under; + over= XkbKeyNameText(key->over.name,XkbXKBFile); + under= XkbKeyNameText(key->under.name,XkbXKBFile); + if (nOut==0) + fprintf(file,"%s %6s=%6s",i_str,under,over); + else if ((nOut%4)==0) + fprintf(file,",\n%s %6s=%6s",i_str,under,over); + else fprintf(file,", %6s=%6s",under,over); + nOut++; + } + } + fprintf(file,"\n%s};\n",i_str); + return True; +} + +static Bool +WriteXKBSection( FILE * file, + Display * dpy, + XkbSectionPtr s, + XkbGeometryPtr geom) +{ +register int i; +XkbRowPtr row; +int dfltKeyColor = 0; + + fprintf(file," section \"%s\" {\n", + XkbAtomText(dpy,s->name,XkbXKBFile)); + if (s->rows&&(s->rows->num_keys>0)) { + dfltKeyColor= s->rows->keys[0].color_ndx; + fprintf(file," key.color= \"%s\";\n", + XkbStringText(geom->colors[dfltKeyColor].spec,XkbXKBFile)); + } + fprintf(file," priority= %d;\n",s->priority); + fprintf(file," top= %s;\n",XkbGeomFPText(s->top,XkbXKBFile)); + fprintf(file," left= %s;\n",XkbGeomFPText(s->left,XkbXKBFile)); + fprintf(file," width= %s;\n",XkbGeomFPText(s->width,XkbXKBFile)); + fprintf(file," height= %s;\n", + XkbGeomFPText(s->height,XkbXKBFile)); + if (s->angle!=0) { + fprintf(file," angle= %s;\n", + XkbGeomFPText(s->angle,XkbXKBFile)); + } + for (i=0,row=s->rows;inum_rows;i++,row++) { + fprintf(file," row {\n"); + fprintf(file," top= %s;\n", + XkbGeomFPText(row->top,XkbXKBFile)); + fprintf(file," left= %s;\n", + XkbGeomFPText(row->left,XkbXKBFile)); + if (row->vertical) + fprintf(file," vertical;\n"); + if (row->num_keys>0) { + register int k; + register XkbKeyPtr key; + int forceNL=0; + int nThisLine= 0; + fprintf(file," keys {\n"); + for (k=0,key=row->keys;knum_keys;k++,key++) { + XkbShapePtr shape; + if (key->color_ndx!=dfltKeyColor) + forceNL= 1; + if (k==0) { + fprintf(file," "); + nThisLine= 0; + } + else if (((nThisLine%2)==1)||(forceNL)) { + fprintf(file,",\n "); + forceNL= nThisLine= 0; + } + else { + fprintf(file,", "); + nThisLine++; + } + shape= XkbKeyShape(geom,key); + fprintf(file,"{ %6s, \"%s\", %3s", + XkbKeyNameText(key->name.name,XkbXKBFile), + XkbAtomText(dpy,shape->name,XkbXKBFile), + XkbGeomFPText(key->gap,XkbXKBFile)); + if (key->color_ndx!=dfltKeyColor) { + fprintf(file,", color=\"%s\"",XkbKeyColor(geom,key)->spec); + forceNL= 1; + } + fprintf(file," }"); + } + fprintf(file,"\n };\n"); + } + fprintf(file," };\n"); + } + if (s->doodads!=NULL) { + XkbDoodadPtr doodad; + for (i=0,doodad=s->doodads;inum_doodads;i++,doodad++) { + WriteXKBDoodad(file,dpy,8,geom,doodad); + } + } + if (s->overlays!=NULL) { + XkbOverlayPtr ol; + for (i=0,ol=s->overlays;inum_overlays;i++,ol++) { + WriteXKBOverlay(file,dpy,8,geom,ol); + } + } + fprintf(file," }; // End of \"%s\" section\n\n", + XkbAtomText(dpy,s->name,XkbXKBFile)); + return True; +} + +Bool +XkbWriteXKBGeometry( FILE * file, + XkbFileInfo * result, + Bool topLevel, + Bool showImplicit, + XkbFileAddOnFunc addOn, + void * priv) +{ +Display * dpy; +register unsigned i,n; +XkbDescPtr xkb; +XkbGeometryPtr geom; + + xkb= result->xkb; + if ((!xkb)||(!xkb->geom)) { + _XkbLibError(_XkbErrMissingGeometry,"XkbWriteXKBGeometry",0); + return False; + } + dpy= xkb->dpy; + geom= xkb->geom; + if (geom->name==None) + fprintf(file,"xkb_geometry {\n\n"); + else fprintf(file,"xkb_geometry \"%s\" {\n\n", + XkbAtomText(dpy,geom->name,XkbXKBFile)); + fprintf(file," width= %s;\n", + XkbGeomFPText(geom->width_mm,XkbXKBFile)); + fprintf(file," height= %s;\n\n", + XkbGeomFPText(geom->height_mm,XkbXKBFile)); + + if (geom->key_aliases!=NULL) { + XkbKeyAliasPtr pAl; + pAl= geom->key_aliases; + for (i=0;inum_key_aliases;i++,pAl++) { + fprintf(file," alias %6s = %6s;\n", + XkbKeyNameText(pAl->alias,XkbXKBFile), + XkbKeyNameText(pAl->real,XkbXKBFile)); + } + fprintf(file,"\n"); + } + + if (geom->base_color!=NULL) + fprintf(file," baseColor= \"%s\";\n", + XkbStringText(geom->base_color->spec,XkbXKBFile)); + if (geom->label_color!=NULL) + fprintf(file," labelColor= \"%s\";\n", + XkbStringText(geom->label_color->spec,XkbXKBFile)); + if (geom->label_font!=NULL) + fprintf(file," xfont= \"%s\";\n", + XkbStringText(geom->label_font,XkbXKBFile)); + if ((geom->num_colors>0)&&(showImplicit)) { + XkbColorPtr color; + for (color=geom->colors,i=0;inum_colors;i++,color++) { + fprintf(file,"// color[%d]= \"%s\"\n",i, + XkbStringText(color->spec,XkbXKBFile)); + } + fprintf(file,"\n"); + } + if (geom->num_properties>0) { + XkbPropertyPtr prop; + for (prop=geom->properties,i=0;inum_properties;i++,prop++) { + fprintf(file," %s= \"%s\";\n",prop->name, + XkbStringText(prop->value,XkbXKBFile)); + } + fprintf(file,"\n"); + } + if (geom->num_shapes>0) { + XkbShapePtr shape; + XkbOutlinePtr outline; + int lastR; + for (shape=geom->shapes,i=0;inum_shapes;i++,shape++) { + lastR=0; + fprintf(file," shape \"%s\" {", + XkbAtomText(dpy,shape->name,XkbXKBFile)); + outline= shape->outlines; + if (shape->num_outlines>1) { + for (n=0;nnum_outlines;n++,outline++) { + if (n==0) fprintf(file,"\n"); + else fprintf(file,",\n"); + WriteXKBOutline(file,shape,outline,lastR,8,8); + lastR= outline->corner_radius; + } + fprintf(file,"\n };\n"); + } + else { + WriteXKBOutline(file,NULL,outline,lastR,1,8); + fprintf(file," };\n"); + } + } + } + if (geom->num_sections>0) { + XkbSectionPtr section; + for (section=geom->sections,i=0;inum_sections;i++,section++){ + WriteXKBSection(file,dpy,section,geom); + } + } + if (geom->num_doodads>0) { + XkbDoodadPtr doodad; + for (i=0,doodad=geom->doodads;inum_doodads;i++,doodad++) { + WriteXKBDoodad(file,dpy,4,geom,doodad); + } + } + if (addOn) + (*addOn)(file,result,topLevel,showImplicit,XkmGeometryIndex,priv); + fprintf(file,"};\n\n"); + return True; +} + +/*ARGSUSED*/ +Bool +XkbWriteXKBSemantics( FILE * file, + XkbFileInfo * result, + Bool topLevel, + Bool showImplicit, + XkbFileAddOnFunc addOn, + void * priv) +{ +Bool ok; + + fprintf(file,"xkb_semantics {\n"); + ok= XkbWriteXKBKeyTypes(file,result,False,False,addOn,priv); + ok= ok&&XkbWriteXKBCompatMap(file,result,False,False,addOn,priv); + fprintf(file,"};\n"); + return ok; +} + +/*ARGSUSED*/ +Bool +XkbWriteXKBLayout( FILE * file, + XkbFileInfo * result, + Bool topLevel, + Bool showImplicit, + XkbFileAddOnFunc addOn, + void * priv) +{ +Bool ok; +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); + fprintf(file,"};\n"); + return ok; +} + +/*ARGSUSED*/ +Bool +XkbWriteXKBKeymap( FILE * file, + XkbFileInfo * result, + Bool topLevel, + Bool showImplicit, + XkbFileAddOnFunc addOn, + void * priv) +{ +Bool ok; +XkbDescPtr xkb; + + xkb= result->xkb; + fprintf(file,"xkb_keymap {\n"); + ok= XkbWriteXKBKeycodes(file,result,False,showImplicit,addOn,priv); + ok= ok&&XkbWriteXKBKeyTypes(file,result,False,showImplicit,addOn,priv); + ok= ok&&XkbWriteXKBCompatMap(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); + fprintf(file,"};\n"); + return ok; +} + +Bool +XkbWriteXKBFile( FILE * out, + XkbFileInfo * result, + Bool showImplicit, + XkbFileAddOnFunc addOn, + void * priv) +{ +Bool ok = False; +Bool (*func)( + FILE * /* file */, + XkbFileInfo * /* result */, + Bool /* topLevel */, + Bool /* showImplicit */, + XkbFileAddOnFunc /* addOn */, + void * /* priv */ +) = NULL; + + switch (result->type) { + case XkmSemanticsFile: + func= XkbWriteXKBSemantics; + break; + case XkmLayoutFile: + func= XkbWriteXKBLayout; + break; + case XkmKeymapFile: + func= XkbWriteXKBKeymap; + break; + case XkmTypesIndex: + func= XkbWriteXKBKeyTypes; + break; + case XkmCompatMapIndex: + func= XkbWriteXKBCompatMap; + break; + case XkmSymbolsIndex: + func= XkbWriteXKBSymbols; + break; + case XkmKeyNamesIndex: + func= XkbWriteXKBKeycodes; + break; + case XkmGeometryFile: + case XkmGeometryIndex: + func= XkbWriteXKBGeometry; + break; + case XkmVirtualModsIndex: + case XkmIndicatorsIndex: + _XkbLibError(_XkbErrBadImplementation, + XkbConfigText(result->type,XkbMessage),0); + return False; + } + if (out==NULL) { + _XkbLibError(_XkbErrFileCannotOpen,"XkbWriteXkbFile",0); + ok= False; + } + else if (func) { + ok= (*func)(out,result,True,showImplicit,addOn,priv); + } + return ok; +} diff --git a/nx-X11/programs/Xserver/xkb/xkbtext.c b/nx-X11/programs/Xserver/xkb/xkbtext.c new file mode 100644 index 000000000..dc1c712ae --- /dev/null +++ b/nx-X11/programs/Xserver/xkb/xkbtext.c @@ -0,0 +1,1325 @@ +/************************************************************ + Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc. + + Permission to use, copy, modify, and distribute this + software and its documentation for any purpose and without + fee is hereby granted, provided that the above copyright + notice appear in all copies and that both that copyright + notice and this permission notice appear in supporting + documentation, and that the name of Silicon Graphics not be + used in advertising or publicity pertaining to distribution + of the software without specific prior written permission. + Silicon Graphics makes no representation about the suitability + of this software for any purpose. It is provided "as is" + without any express or implied warranty. + + SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS + SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON + GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE + OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH + THE USE OR PERFORMANCE OF THIS SOFTWARE. + + ********************************************************/ + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#include +#include +#include + +#include + +#include +#include +#include "misc.h" +#include "inputstr.h" +#include "dix.h" +#include "xkbstr.h" +#include +#include "xkbgeom.h" + +/***====================================================================***/ + +#define BUFFER_SIZE 512 + +static char textBuffer[BUFFER_SIZE]; +static int tbNext= 0; + +static char * +tbGetBuffer(unsigned size) +{ +char *rtrn; + + if (size>=BUFFER_SIZE) + return NULL; + if ((BUFFER_SIZE-tbNext)<=size) + tbNext= 0; + rtrn= &textBuffer[tbNext]; + tbNext+= size; + return rtrn; +} + +/***====================================================================***/ + +char * +XkbAtomText(Display *dpy,Atom atm,unsigned format) +{ +const char *atmstr; +char *rtrn,*tmp; + + atmstr= NameForAtom(atm); + if (atmstr!=NULL) { + int len; + len= strlen(atmstr)+1; + if (len>BUFFER_SIZE) + len= BUFFER_SIZE-2; + rtrn= tbGetBuffer(len); + strncpy(rtrn,atmstr,len); + rtrn[len]= '\0'; + } + else { + rtrn= tbGetBuffer(1); + rtrn[0]= '\0'; + } + if (format==XkbCFile) { + for (tmp=rtrn;*tmp!='\0';tmp++) { + if ((tmp==rtrn)&&(!isalpha(*tmp))) + *tmp= '_'; + else if (!isalnum(*tmp)) + *tmp= '_'; + } + } + return XkbStringText(rtrn,format); +} + +/***====================================================================***/ + +char * +XkbVModIndexText(Display *dpy,XkbDescPtr xkb,unsigned ndx,unsigned format) +{ +register int len; +register Atom *vmodNames; +char *rtrn; +const char *tmp; +char numBuf[20]; + + if (xkb && xkb->names) + vmodNames= xkb->names->vmods; + else vmodNames= NULL; + + tmp= NULL; + if (ndx>=XkbNumVirtualMods) + tmp= "illegal"; + else if (vmodNames&&(vmodNames[ndx]!=None)) + tmp= NameForAtom(vmodNames[ndx]); + if (tmp==NULL) { + sprintf(numBuf,"%d",ndx); + tmp = numBuf; + } + + len= strlen(tmp)+1; + if (format==XkbCFile) + len+= 4; + if (len>=BUFFER_SIZE) + len= BUFFER_SIZE-1; + rtrn= tbGetBuffer(len); + if (format==XkbCFile) { + strcpy(rtrn,"vmod_"); + strncpy(&rtrn[5],tmp,len-4); + } + else strncpy(rtrn,tmp,len); + return rtrn; +} + +char * +XkbVModMaskText( Display * dpy, + XkbDescPtr xkb, + unsigned modMask, + unsigned mask, + unsigned format) +{ +register int i,bit; +int len; +char *mm,*rtrn; +char *str,buf[BUFFER_SIZE]; + + if ((modMask==0)&&(mask==0)) { + rtrn= tbGetBuffer(5); + if (format==XkbCFile) + sprintf(rtrn,"0"); + else sprintf(rtrn,"none"); + return rtrn; + } + if (modMask!=0) + mm= XkbModMaskText(modMask,format); + else mm= NULL; + + str= buf; + buf[0]= '\0'; + if (mask) { + char *tmp; + for (i=0,bit=1;i=BUFFER_SIZE) + len= BUFFER_SIZE-1; + rtrn= tbGetBuffer(len+1); + rtrn[0]= '\0'; + + if (mm!=NULL) { + i= strlen(mm); + if (i>len) + i= len; + strcpy(rtrn,mm); + } + else { + i=0; + } + if (str!=NULL) { + if (mm!=NULL) { + if (format==XkbCFile) strcat(rtrn,"|"); + else strcat(rtrn,"+"); + } + strncat(rtrn,str,len-i); + } + rtrn[len]= '\0'; + return rtrn; +} + +static char *modNames[XkbNumModifiers] = { + "Shift", "Lock", "Control", "Mod1", "Mod2", "Mod3", "Mod4", "Mod5" +}; + +char * +XkbModIndexText(unsigned ndx,unsigned format) +{ +char * rtrn; +char buf[100]; + + if (format==XkbCFile) { + if (ndx0) { + len= strlen(from); + if (len<((*pLeft)-3)) { + strcat(to,from); + *pLeft-= len; + return True; + } + } + *pLeft= -1; + return False; +} + +/*ARGSUSED*/ +static Bool +CopyNoActionArgs(Display *dpy,XkbDescPtr xkb,XkbAction *action,char *buf,int*sz) +{ + return True; +} + +static Bool +CopyModActionArgs(Display *dpy,XkbDescPtr xkb,XkbAction *action,char *buf, + int* sz) +{ +XkbModAction * act; +unsigned tmp; + + act= &action->mods; + tmp= XkbModActionVMods(act); + TryCopyStr(buf,"modifiers=",sz); + if (act->flags&XkbSA_UseModMapMods) + TryCopyStr(buf,"modMapMods",sz); + else if (act->real_mods || tmp) { + TryCopyStr(buf, + XkbVModMaskText(dpy,xkb,act->real_mods,tmp,XkbXKBFile), + sz); + } + else TryCopyStr(buf,"none",sz); + if (act->type==XkbSA_LockMods) + return True; + if (act->flags&XkbSA_ClearLocks) + TryCopyStr(buf,",clearLocks",sz); + if (act->flags&XkbSA_LatchToLock) + TryCopyStr(buf,",latchToLock",sz); + return True; +} + +/*ARGSUSED*/ +static Bool +CopyGroupActionArgs(Display *dpy,XkbDescPtr xkb,XkbAction *action,char *buf, + int *sz) +{ +XkbGroupAction * act; +char tbuf[32]; + + act= &action->group; + TryCopyStr(buf,"group=",sz); + if (act->flags&XkbSA_GroupAbsolute) + sprintf(tbuf,"%d",XkbSAGroup(act)+1); + else if (XkbSAGroup(act)<0) + sprintf(tbuf,"%d",XkbSAGroup(act)); + else sprintf(tbuf,"+%d",XkbSAGroup(act)); + TryCopyStr(buf,tbuf,sz); + if (act->type==XkbSA_LockGroup) + return True; + if (act->flags&XkbSA_ClearLocks) + TryCopyStr(buf,",clearLocks",sz); + if (act->flags&XkbSA_LatchToLock) + TryCopyStr(buf,",latchToLock",sz); + return True; +} + +/*ARGSUSED*/ +static Bool +CopyMovePtrArgs(Display *dpy,XkbDescPtr xkb,XkbAction *action,char *buf,int *sz) +{ +XkbPtrAction * act; +int x,y; +char tbuf[32]; + + act= &action->ptr; + x= XkbPtrActionX(act); + y= XkbPtrActionY(act); + if ((act->flags&XkbSA_MoveAbsoluteX)||(x<0)) + sprintf(tbuf,"x=%d",x); + else sprintf(tbuf,"x=+%d",x); + TryCopyStr(buf,tbuf,sz); + + if ((act->flags&XkbSA_MoveAbsoluteY)||(y<0)) + sprintf(tbuf,",y=%d",y); + else sprintf(tbuf,",y=+%d",y); + TryCopyStr(buf,tbuf,sz); + if (act->flags&XkbSA_NoAcceleration) + TryCopyStr(buf,",!accel",sz); + return True; +} + +/*ARGSUSED*/ +static Bool +CopyPtrBtnArgs(Display *dpy,XkbDescPtr xkb,XkbAction *action,char *buf,int *sz) +{ +XkbPtrBtnAction * act; +char tbuf[32]; + + act= &action->btn; + TryCopyStr(buf,"button=",sz); + if ((act->button>0)&&(act->button<6)) { + sprintf(tbuf,"%d",act->button); + TryCopyStr(buf,tbuf,sz); + } + else TryCopyStr(buf,"default",sz); + if (act->count>0) { + sprintf(tbuf,",count=%d",act->count); + TryCopyStr(buf,tbuf,sz); + } + if (action->type==XkbSA_LockPtrBtn) { + switch (act->flags&(XkbSA_LockNoUnlock|XkbSA_LockNoLock)) { + case XkbSA_LockNoLock: + sprintf(tbuf,",affect=unlock"); break; + case XkbSA_LockNoUnlock: + sprintf(tbuf,",affect=lock"); break; + case XkbSA_LockNoUnlock|XkbSA_LockNoLock: + sprintf(tbuf,",affect=neither"); break; + default: + sprintf(tbuf,",affect=both"); break; + } + TryCopyStr(buf,tbuf,sz); + } + return True; +} + +/*ARGSUSED*/ +static Bool +CopySetPtrDfltArgs(Display *dpy,XkbDescPtr xkb,XkbAction *action,char *buf, + int *sz) +{ +XkbPtrDfltAction * act; +char tbuf[32]; + + act= &action->dflt; + if (act->affect==XkbSA_AffectDfltBtn) { + TryCopyStr(buf,"affect=button,button=",sz); + if ((act->flags&XkbSA_DfltBtnAbsolute)||(XkbSAPtrDfltValue(act)<0)) + sprintf(tbuf,"%d",XkbSAPtrDfltValue(act)); + else sprintf(tbuf,"+%d",XkbSAPtrDfltValue(act)); + TryCopyStr(buf,tbuf,sz); + } + return True; +} + +static Bool +CopyISOLockArgs(Display *dpy,XkbDescPtr xkb,XkbAction *action,char *buf,int *sz) +{ +XkbISOAction * act; +char tbuf[64]; + + act= &action->iso; + if (act->flags&XkbSA_ISODfltIsGroup) { + TryCopyStr(tbuf,"group=",sz); + if (act->flags&XkbSA_GroupAbsolute) + sprintf(tbuf,"%d",XkbSAGroup(act)+1); + else if (XkbSAGroup(act)<0) + sprintf(tbuf,"%d",XkbSAGroup(act)); + else sprintf(tbuf,"+%d",XkbSAGroup(act)); + TryCopyStr(buf,tbuf,sz); + } + else { + unsigned tmp; + tmp= XkbModActionVMods(act); + TryCopyStr(buf,"modifiers=",sz); + if (act->flags&XkbSA_UseModMapMods) + TryCopyStr(buf,"modMapMods",sz); + else if (act->real_mods || tmp) { + if (act->real_mods) { + TryCopyStr(buf,XkbModMaskText(act->real_mods,XkbXKBFile),sz); + if (tmp) + TryCopyStr(buf,"+",sz); + } + if (tmp) + TryCopyStr(buf,XkbVModMaskText(dpy,xkb,0,tmp,XkbXKBFile),sz); + } + else TryCopyStr(buf,"none",sz); + } + TryCopyStr(buf,",affect=",sz); + if ((act->affect&XkbSA_ISOAffectMask)==0) + TryCopyStr(buf,"all",sz); + else { + int nOut= 0; + if ((act->affect&XkbSA_ISONoAffectMods)==0) { + TryCopyStr(buf,"mods",sz); + nOut++; + } + if ((act->affect&XkbSA_ISONoAffectGroup)==0) { + sprintf(tbuf,"%sgroups",(nOut>0?"+":"")); + TryCopyStr(buf,tbuf,sz); + nOut++; + } + if ((act->affect&XkbSA_ISONoAffectPtr)==0) { + sprintf(tbuf,"%spointer",(nOut>0?"+":"")); + TryCopyStr(buf,tbuf,sz); + nOut++; + } + if ((act->affect&XkbSA_ISONoAffectCtrls)==0) { + sprintf(tbuf,"%scontrols",(nOut>0?"+":"")); + TryCopyStr(buf,tbuf,sz); + nOut++; + } + } + return True; +} + +/*ARGSUSED*/ +static Bool +CopySwitchScreenArgs(Display *dpy,XkbDescPtr xkb,XkbAction *action,char *buf, + int *sz) +{ +XkbSwitchScreenAction * act; +char tbuf[32]; + + act= &action->screen; + if ((act->flags&XkbSA_SwitchAbsolute)||(XkbSAScreen(act)<0)) + sprintf(tbuf,"screen=%d",XkbSAScreen(act)); + else sprintf(tbuf,"screen=+%d",XkbSAScreen(act)); + TryCopyStr(buf,tbuf,sz); + if (act->flags&XkbSA_SwitchApplication) + TryCopyStr(buf,",!same",sz); + else TryCopyStr(buf,",same",sz); + return True; +} + +/*ARGSUSED*/ +static Bool +CopySetLockControlsArgs(Display *dpy,XkbDescPtr xkb,XkbAction *action, + char *buf,int *sz) +{ +XkbCtrlsAction * act; +unsigned tmp; +char tbuf[32]; + + act= &action->ctrls; + tmp= XkbActionCtrls(act); + TryCopyStr(buf,"controls=",sz); + if (tmp==0) + TryCopyStr(buf,"none",sz); + else if ((tmp&XkbAllBooleanCtrlsMask)==XkbAllBooleanCtrlsMask) + TryCopyStr(buf,"all",sz); + else { + int nOut= 0; + if (tmp&XkbRepeatKeysMask) { + sprintf(tbuf,"%sRepeatKeys",(nOut>0?"+":"")); + TryCopyStr(buf,tbuf,sz); + nOut++; + } + if (tmp&XkbSlowKeysMask) { + sprintf(tbuf,"%sSlowKeys",(nOut>0?"+":"")); + TryCopyStr(buf,tbuf,sz); + nOut++; + } + if (tmp&XkbBounceKeysMask) { + sprintf(tbuf,"%sBounceKeys",(nOut>0?"+":"")); + TryCopyStr(buf,tbuf,sz); + nOut++; + } + if (tmp&XkbStickyKeysMask) { + sprintf(tbuf,"%sStickyKeys",(nOut>0?"+":"")); + TryCopyStr(buf,tbuf,sz); + nOut++; + } + if (tmp&XkbMouseKeysMask) { + sprintf(tbuf,"%sMouseKeys",(nOut>0?"+":"")); + TryCopyStr(buf,tbuf,sz); + nOut++; + } + if (tmp&XkbMouseKeysAccelMask) { + sprintf(tbuf,"%sMouseKeysAccel",(nOut>0?"+":"")); + TryCopyStr(buf,tbuf,sz); + nOut++; + } + if (tmp&XkbAccessXKeysMask) { + sprintf(tbuf,"%sAccessXKeys",(nOut>0?"+":"")); + TryCopyStr(buf,tbuf,sz); + nOut++; + } + if (tmp&XkbAccessXTimeoutMask) { + sprintf(tbuf,"%sAccessXTimeout",(nOut>0?"+":"")); + TryCopyStr(buf,tbuf,sz); + nOut++; + } + if (tmp&XkbAccessXFeedbackMask) { + sprintf(tbuf,"%sAccessXFeedback",(nOut>0?"+":"")); + TryCopyStr(buf,tbuf,sz); + nOut++; + } + if (tmp&XkbAudibleBellMask) { + sprintf(tbuf,"%sAudibleBell",(nOut>0?"+":"")); + TryCopyStr(buf,tbuf,sz); + nOut++; + } + if (tmp&XkbOverlay1Mask) { + sprintf(tbuf,"%sOverlay1",(nOut>0?"+":"")); + TryCopyStr(buf,tbuf,sz); + nOut++; + } + if (tmp&XkbOverlay2Mask) { + sprintf(tbuf,"%sOverlay2",(nOut>0?"+":"")); + TryCopyStr(buf,tbuf,sz); + nOut++; + } + if (tmp&XkbIgnoreGroupLockMask) { + sprintf(tbuf,"%sIgnoreGroupLock",(nOut>0?"+":"")); + TryCopyStr(buf,tbuf,sz); + nOut++; + } + } + return True; +} + +/*ARGSUSED*/ +static Bool +CopyActionMessageArgs(Display *dpy,XkbDescPtr xkb,XkbAction *action,char *buf, + int *sz) +{ +XkbMessageAction * act; +unsigned all; +char tbuf[32]; + + act= &action->msg; + all= XkbSA_MessageOnPress|XkbSA_MessageOnRelease; + TryCopyStr(buf,"report=",sz); + if ((act->flags&all)==0) + TryCopyStr(buf,"none",sz); + else if ((act->flags&all)==all) + TryCopyStr(buf,"all",sz); + else if (act->flags&XkbSA_MessageOnPress) + TryCopyStr(buf,"KeyPress",sz); + else TryCopyStr(buf,"KeyRelease",sz); + sprintf(tbuf,",data[0]=0x%02x",act->message[0]); TryCopyStr(buf,tbuf,sz); + sprintf(tbuf,",data[1]=0x%02x",act->message[1]); TryCopyStr(buf,tbuf,sz); + sprintf(tbuf,",data[2]=0x%02x",act->message[2]); TryCopyStr(buf,tbuf,sz); + sprintf(tbuf,",data[3]=0x%02x",act->message[3]); TryCopyStr(buf,tbuf,sz); + sprintf(tbuf,",data[4]=0x%02x",act->message[4]); TryCopyStr(buf,tbuf,sz); + sprintf(tbuf,",data[5]=0x%02x",act->message[5]); TryCopyStr(buf,tbuf,sz); + return True; +} + +static Bool +CopyRedirectKeyArgs(Display *dpy,XkbDescPtr xkb,XkbAction *action,char *buf, + int *sz) +{ +XkbRedirectKeyAction * act; +char tbuf[32],*tmp; +unsigned kc; +unsigned vmods,vmods_mask; + + act= &action->redirect; + kc= act->new_key; + vmods= XkbSARedirectVMods(act); + vmods_mask= XkbSARedirectVModsMask(act); + if (xkb && xkb->names && xkb->names->keys && (kc<=xkb->max_key_code) && + (xkb->names->keys[kc].name[0]!='\0')) { + char *kn; + kn= XkbKeyNameText(xkb->names->keys[kc].name,XkbXKBFile); + sprintf(tbuf,"key=%s",kn); + } + else sprintf(tbuf,"key=%d",kc); + TryCopyStr(buf,tbuf,sz); + if ((act->mods_mask==0)&&(vmods_mask==0)) + return True; + if ((act->mods_mask==XkbAllModifiersMask)&& + (vmods_mask==XkbAllVirtualModsMask)) { + tmp= XkbVModMaskText(dpy,xkb,act->mods,vmods,XkbXKBFile); + TryCopyStr(buf,",mods=",sz); + TryCopyStr(buf,tmp,sz); + } + else { + if ((act->mods_mask&act->mods)||(vmods_mask&vmods)) { + tmp= XkbVModMaskText(dpy,xkb,act->mods_mask&act->mods, + vmods_mask&vmods,XkbXKBFile); + TryCopyStr(buf,",mods= ",sz); + TryCopyStr(buf,tmp,sz); + } + if ((act->mods_mask&(~act->mods))||(vmods_mask&(~vmods))) { + tmp= XkbVModMaskText(dpy,xkb,act->mods_mask&(~act->mods), + vmods_mask&(~vmods),XkbXKBFile); + TryCopyStr(buf,",clearMods= ",sz); + TryCopyStr(buf,tmp,sz); + } + } + return True; +} + +/*ARGSUSED*/ +static Bool +CopyDeviceBtnArgs(Display *dpy,XkbDescPtr xkb,XkbAction *action,char *buf, + int *sz) +{ +XkbDeviceBtnAction * act; +char tbuf[32]; + + act= &action->devbtn; + sprintf(tbuf,"device= %d",act->device); TryCopyStr(buf,tbuf,sz); + TryCopyStr(buf,",button=",sz); + sprintf(tbuf,"%d",act->button); + TryCopyStr(buf,tbuf,sz); + if (act->count>0) { + sprintf(tbuf,",count=%d",act->count); + TryCopyStr(buf,tbuf,sz); + } + if (action->type==XkbSA_LockDeviceBtn) { + switch (act->flags&(XkbSA_LockNoUnlock|XkbSA_LockNoLock)) { + case XkbSA_LockNoLock: + sprintf(tbuf,",affect=unlock"); break; + case XkbSA_LockNoUnlock: + sprintf(tbuf,",affect=lock"); break; + case XkbSA_LockNoUnlock|XkbSA_LockNoLock: + sprintf(tbuf,",affect=neither"); break; + default: + sprintf(tbuf,",affect=both"); break; + } + TryCopyStr(buf,tbuf,sz); + } + return True; +} + +/*ARGSUSED*/ +static Bool +CopyOtherArgs(Display *dpy,XkbDescPtr xkb,XkbAction *action,char *buf,int *sz) +{ +XkbAnyAction * act; +char tbuf[32]; + + act= &action->any; + sprintf(tbuf,"type=0x%02x",act->type); TryCopyStr(buf,tbuf,sz); + sprintf(tbuf,",data[0]=0x%02x",act->data[0]); TryCopyStr(buf,tbuf,sz); + sprintf(tbuf,",data[1]=0x%02x",act->data[1]); TryCopyStr(buf,tbuf,sz); + sprintf(tbuf,",data[2]=0x%02x",act->data[2]); TryCopyStr(buf,tbuf,sz); + sprintf(tbuf,",data[3]=0x%02x",act->data[3]); TryCopyStr(buf,tbuf,sz); + sprintf(tbuf,",data[4]=0x%02x",act->data[4]); TryCopyStr(buf,tbuf,sz); + sprintf(tbuf,",data[5]=0x%02x",act->data[5]); TryCopyStr(buf,tbuf,sz); + sprintf(tbuf,",data[6]=0x%02x",act->data[6]); TryCopyStr(buf,tbuf,sz); + return True; +} + +typedef Bool (*actionCopy)( + Display * /* dpy */, + XkbDescPtr /* xkb */, + XkbAction * /* action */, + char * /* buf */, + int* /* sz */ +); +static actionCopy copyActionArgs[XkbSA_NumActions] = { + CopyNoActionArgs /* NoAction */, + CopyModActionArgs /* SetMods */, + CopyModActionArgs /* LatchMods */, + CopyModActionArgs /* LockMods */, + CopyGroupActionArgs /* SetGroup */, + CopyGroupActionArgs /* LatchGroup */, + CopyGroupActionArgs /* LockGroup */, + CopyMovePtrArgs /* MovePtr */, + CopyPtrBtnArgs /* PtrBtn */, + CopyPtrBtnArgs /* LockPtrBtn */, + CopySetPtrDfltArgs /* SetPtrDflt */, + CopyISOLockArgs /* ISOLock */, + CopyNoActionArgs /* Terminate */, + CopySwitchScreenArgs /* SwitchScreen */, + CopySetLockControlsArgs /* SetControls */, + CopySetLockControlsArgs /* LockControls */, + CopyActionMessageArgs /* ActionMessage*/, + CopyRedirectKeyArgs /* RedirectKey */, + CopyDeviceBtnArgs /* DeviceBtn */, + CopyDeviceBtnArgs /* LockDeviceBtn*/ +}; + +#define ACTION_SZ 256 + +char * +XkbActionText(Display *dpy,XkbDescPtr xkb,XkbAction *action,unsigned format) +{ +char buf[ACTION_SZ],*tmp; +int sz; + + if (format==XkbCFile) { + sprintf(buf, + "{ %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], + action->any.data[6]); + } + else { + sprintf(buf,"%s(",XkbActionTypeText(action->type,XkbXKBFile)); + sz= ACTION_SZ-strlen(buf)+2; /* room for close paren and NULL */ + if (action->type<(unsigned)XkbSA_NumActions) + (*copyActionArgs[action->type])(dpy,xkb,action,buf,&sz); + else CopyOtherArgs(dpy,xkb,action,buf,&sz); + TryCopyStr(buf,")",&sz); + } + tmp= tbGetBuffer(strlen(buf)+1); + if (tmp!=NULL) + strcpy(tmp,buf); + return tmp; +} + +char * +XkbBehaviorText(XkbDescPtr xkb,XkbBehavior *behavior,unsigned format) +{ +char buf[256],*tmp; + + if (format==XkbCFile) { + if (behavior->type==XkbKB_Default) + sprintf(buf,"{ 0, 0 }"); + else sprintf(buf,"{ %3d, 0x%02x }",behavior->type,behavior->data); + } + else { + unsigned type,permanent; + type= behavior->type&XkbKB_OpMask; + permanent=((behavior->type&XkbKB_Permanent)!=0); + + if (type==XkbKB_Lock) { + sprintf(buf,"lock= %s",(permanent?"Permanent":"True")); + } + else if (type==XkbKB_RadioGroup) { + int g; + char *tmp; + g= ((behavior->data)&(~XkbKB_RGAllowNone))+1; + if (XkbKB_RGAllowNone&behavior->data) { + sprintf(buf,"allowNone,"); + tmp= &buf[strlen(buf)]; + } + else tmp= buf; + if (permanent) + sprintf(tmp,"permanentRadioGroup= %d",g); + else sprintf(tmp,"radioGroup= %d",g); + } + else if ((type==XkbKB_Overlay1)||(type==XkbKB_Overlay2)) { + int ndx,kc; + char *kn; + + ndx= ((type==XkbKB_Overlay1)?1:2); + kc= behavior->data; + if ((xkb)&&(xkb->names)&&(xkb->names->keys)) + kn= XkbKeyNameText(xkb->names->keys[kc].name,XkbXKBFile); + else { + static char tbuf[8]; + sprintf(tbuf,"%d",kc); + kn= tbuf; + } + if (permanent) + sprintf(buf,"permanentOverlay%d= %s",ndx,kn); + else sprintf(buf,"overlay%d= %s",ndx,kn); + } + } + tmp= tbGetBuffer(strlen(buf)+1); + if (tmp!=NULL) + strcpy(tmp,buf); + return tmp; +} + +/***====================================================================***/ + +char * +XkbIndentText(unsigned size) +{ +static char buf[32]; +register int i; + + if (size>31) + size= 31; + + for (i=0;i> 8; - rtrn= 0; - switch (set) { - case 0: /* latin 1 */ - 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 (ks==XK_oe) { - rtrn|= _XkbKSLower; - } - break; - } - return rtrn; -} - /***====================================================================***/ static int @@ -1226,10 +1143,14 @@ int nRead; *loaded_rtrn|= XkmGeometryMask; break; default: + _XkbLibError(_XkbErrBadImplementation, + XkbConfigText(tmpTOC.type,XkbMessage),0); nRead= 0; break; } if (nRead!=tmpTOC.size) { + _XkbLibError(_XkbErrBadLength,XkbConfigText(tmpTOC.type,XkbMessage), + nRead-tmpTOC.size); return 0; } return (nRead>=0); @@ -1264,6 +1185,8 @@ char name[100]; return Xstrdup(name); break; default: + _XkbLibError(_XkbErrBadImplementation, + XkbConfigText(tmpTOC.type,XkbMessage),0); break; } return NULL; @@ -1329,6 +1252,8 @@ unsigned which= need|want; tmp= ReadXkmGeometry(file,result); break; default: + _XkbLibError(_XkbErrBadImplementation, + XkbConfigText(tmpTOC.type,XkbMessage),0); tmp= 0; break; } @@ -1338,7 +1263,8 @@ unsigned which= need|want; result->defined|= (1< Date: Wed, 4 Jul 2018 23:15:11 +0200 Subject: Keyboard.c: Remove (now) unused defines --- nx-X11/programs/Xserver/hw/nxagent/Keyboard.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c index c6998e8be..1c6fcaab0 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c @@ -148,12 +148,6 @@ extern Status XkbGetControls( #ifndef XKB_ALTERNATE_BASE_DIRECTORY #define XKB_ALTERNATE_BASE_DIRECTORY "/usr/X11R6/lib/X11/xkb" #endif -#ifndef XKB_CONFIG_FILE_NX -#define XKB_CONFIG_FILE_NX "/etc/nxagent/nxagent.keyboard" -#endif -#ifndef XKB_CONFIG_FILE_X2GO -#define XKB_CONFIG_FILE_X2GO "/etc/x2go/x2goagent.keyboard" -#endif #ifndef XKB_DFLT_RULES_FILE #define XKB_DFLT_RULES_FILE "base" #endif -- cgit v1.2.3 From 0fc53688698d128ac77a998b87e5b0df3d44c622 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Wed, 4 Jul 2018 23:16:26 +0200 Subject: Keyboard.c: remove unnecessary includes --- nx-X11/programs/Xserver/hw/nxagent/Keyboard.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c index 1c6fcaab0..647a0a823 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c @@ -42,15 +42,12 @@ is" without express or implied warranty. #include #include -#include "X.h" -#include "Xproto.h" #include "keysym.h" #include "screenint.h" #include "inputstr.h" #include "misc.h" #include "scrnintstr.h" #include "servermd.h" -#include "dixstruct.h" #include "extnsionst.h" #include "Agent.h" @@ -67,10 +64,6 @@ is" without express or implied warranty. #ifdef XKB -#include "globals.h" -#include "property.h" -#include "Init.h" - #include /* -- cgit v1.2.3 From d54f1fb7360ab2f35d916b53baba3e3aee8d9128 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 5 Jul 2018 23:14:05 +0200 Subject: Keyboard.c: remove unused defines Defines regarding XKB-BASE_DIRECTORY are used only xkb. --- nx-X11/programs/Xserver/hw/nxagent/Keyboard.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c index 647a0a823..5abfc70d5 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c @@ -135,12 +135,6 @@ extern Status XkbGetControls( #endif ); -#ifndef XKB_BASE_DIRECTORY -#define XKB_BASE_DIRECTORY "/usr/share/X11/xkb" -#endif -#ifndef XKB_ALTERNATE_BASE_DIRECTORY -#define XKB_ALTERNATE_BASE_DIRECTORY "/usr/X11R6/lib/X11/xkb" -#endif #ifndef XKB_DFLT_RULES_FILE #define XKB_DFLT_RULES_FILE "base" #endif -- cgit v1.2.3 From 11a1f31d70c189bf6c5f4420f196468267755a0d Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 5 Jul 2018 23:16:30 +0200 Subject: no more own XkbBaseDirectory handling Just use the existing xkb code --- nx-X11/programs/Xserver/hw/nxagent/Keyboard.c | 33 --- nx-X11/programs/Xserver/xkb/ddxLoad.c | 329 +------------------------- 2 files changed, 1 insertion(+), 361 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c index 5abfc70d5..d943ec2c4 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c @@ -481,37 +481,6 @@ static int nxagentRestoreKeyboardDeviceData(DeviceIntPtr devBackup, DeviceIntPtr static int nxagentFreeKeyboardDeviceData(DeviceIntPtr dev); -static void nxagentCheckXkbBaseDirectory(void) -{ - - /* - * Set XkbBaseDirectory global - * variable appropriately. - */ - - #ifdef TEST - fprintf(stderr, "nxagentCheckXkbBaseDirectory: " - "Before calling _NXGetXkbBasePath:\n"); - - fprintf(stderr, "nxagentCheckXkbBaseDirectory: " - "XkbBaseDirectory variable [%s].\n", - XkbBaseDirectory); - #endif - - XkbBaseDirectory = _NXGetXkbBasePath(XkbBaseDirectory); - - #ifdef TEST - fprintf(stderr, "nxagentCheckXkbBaseDirectory: " - "After calling _NXGetXkbBasePath:\n"); - - fprintf(stderr, "nxagentCheckXkbBaseDirectory: " - "XkbBaseDirectory variable [%s].\n", - XkbBaseDirectory); - #endif - - return; -} - static char *nxagentXkbGetRules() { int ret; @@ -820,8 +789,6 @@ N/A * variable is checked. */ - nxagentCheckXkbBaseDirectory(); - if (noXkbExtension) { #ifdef TEST fprintf(stderr, "nxagentKeyboardProc: No XKB extension.\n"); diff --git a/nx-X11/programs/Xserver/xkb/ddxLoad.c b/nx-X11/programs/Xserver/xkb/ddxLoad.c index f710af285..fca0cd62f 100644 --- a/nx-X11/programs/Xserver/xkb/ddxLoad.c +++ b/nx-X11/programs/Xserver/xkb/ddxLoad.c @@ -178,310 +178,6 @@ Win32System(const char *cmdline) # endif #endif -#ifdef NXAGENT_SERVER - -#define NX_XKB_BASE_DIRECTORY "/usr/lib/X11/xkb" -#define NX_XKB_ALTERNATE_BASE_DIRECTORY "/usr/share/X11/xkb" -#define NX_XKB_RULES_BASE_FILE "rules/base" -#define NX_ALT_XKBCOMP_PATH "/usr/bin" - -static char _NXXkbBasePath[PATH_MAX]; -static char _NXXkbCompPath[PATH_MAX]; - -static int NXVerifyXkbBaseDirectory(const char *dirPath) -{ - int size; - char *rulesBaseFilePath; - struct stat rulesBaseFileStat; - - /* - * If rules/base file - * is not present inside - * the Xkb Base Directory, - * we suppose that the - * path is not valid. - */ - - size = strlen(dirPath) + strlen("/") + - strlen(NX_XKB_RULES_BASE_FILE) + 1; - - if ((rulesBaseFilePath = malloc((size + 1) * sizeof(char))) == NULL) - { - FatalError("NXVerifyXkbBaseDirectory: malloc failed.\n"); - } - - strcpy(rulesBaseFilePath, dirPath); - strcat(rulesBaseFilePath, "/"); - strcat(rulesBaseFilePath, NX_XKB_RULES_BASE_FILE); - - #ifdef TEST - fprintf(stderr, "NXVerifyXkbBaseDirectory: Looking for [%s] file.\n", - rulesBaseFilePath); - #endif - - if (stat(rulesBaseFilePath, &rulesBaseFileStat) != 0) - { - - #ifdef TEST - fprintf(stderr, "NXVerifyXkbBaseDirectory: Xkb Base Directory [%s] is not valid (can't find file [%s]).\n", - dirPath, rulesBaseFilePath); - #endif - - free(rulesBaseFilePath); - - return 0; - } - - #ifdef TEST - fprintf(stderr, "NXVerifyXkbBaseDirectory: Xkb Base Directory [%s] is valid.\n", - dirPath); - #endif - - free(rulesBaseFilePath); - - return 1; -} - -/* - * This function returns the directory - * containing the configuration files. - * This directory is referred by Xkb- - * BaseDirectory variable (generally - * it contains the hardcoded path at - * compile time). If the directory - * does not exist, the function will - * try a set of well known directories. - */ - -char *_NXGetXkbBasePath(const char *path) -{ - /* - * Check the xkb base directory only once. - */ - - if (*_NXXkbBasePath != '\0') - { - return _NXXkbBasePath; - } - - if (NXVerifyXkbBaseDirectory(XkbBaseDirectory) == 1) - { - if (strlen(XkbBaseDirectory) + 1 > PATH_MAX) - { - #ifdef TEST - fprintf(stderr, "_NXGetXkbBasePath: WARNING! Maximum length of xkb base path exceeded.\n"); - #endif - - goto _NXGetXkbBasePathError; - } - - strcpy(_NXXkbBasePath, XkbBaseDirectory); - - #ifdef TEST - fprintf(stderr, "_NXGetXkbBasePath: Using NX xkb base directory path [%s].\n", - _NXXkbBasePath); - #endif - - return _NXXkbBasePath; - } - - if (NXVerifyXkbBaseDirectory(NX_XKB_BASE_DIRECTORY) == 1) - { - if (strlen(NX_XKB_BASE_DIRECTORY) + 1 > PATH_MAX) - { - #ifdef TEST - fprintf(stderr, "_NXGetXkbBasePath: WARNING! Maximum length of xkb base path exceeded.\n"); - #endif - - goto _NXGetXkbBasePathError; - } - - strcpy(_NXXkbBasePath, NX_XKB_BASE_DIRECTORY); - - #ifdef TEST - fprintf(stderr, "_NXGetXkbBasePath: Using NX xkb base directory path [%s].\n", - _NXXkbBasePath); - #endif - - return _NXXkbBasePath; - } - - if (NXVerifyXkbBaseDirectory(NX_XKB_ALTERNATE_BASE_DIRECTORY) == 1) - { - if (strlen(NX_XKB_ALTERNATE_BASE_DIRECTORY) + 1 > PATH_MAX) - { - #ifdef TEST - fprintf(stderr, "_NXGetXkbBasePath: WARNING! Maximum length of xkb base path exceeded.\n"); - #endif - - goto _NXGetXkbBasePathError; - } - - strcpy(_NXXkbBasePath, NX_XKB_ALTERNATE_BASE_DIRECTORY); - - #ifdef TEST - fprintf(stderr, "_NXGetXkbBasePath: Using NX xkb base directory path [%s].\n", - _NXXkbBasePath); - #endif - - return _NXXkbBasePath; - } - -_NXGetXkbBasePathError: - - if (strlen(path) + 1 > PATH_MAX) - { - #ifdef TEST - fprintf(stderr, "_NXGetXkbBasePath: WARNING! Maximum length of xkb base path exceeded.\n"); - #endif - } - - strcpy(_NXXkbBasePath, path); - - #ifdef TEST - fprintf(stderr, "_NXGetXkbBasePath: Using default xkb base path [%s].\n", - _NXXkbBasePath); - #endif - - return _NXXkbBasePath; -} - -static int NXVerifyXkbCompPath(char *path) -{ - char *xkbCompPath; - int xkbCompPathSize; - struct stat xkbCompPathStat; - - if (path == NULL) - { - return 0; - } - - xkbCompPathSize = strlen(path) + strlen("/") + - strlen("xkbcomp") + 1; - - if ((xkbCompPath = malloc((xkbCompPathSize + 1) * sizeof(char))) == NULL) - { - FatalError("NXVerifyXkbCompPath: WARNING! malloc failed.\n"); - - return 0; - } - - strcpy(xkbCompPath, path); - strcat(xkbCompPath, "/"); - strcat(xkbCompPath, "xkbcomp"); - - if (stat(xkbCompPath, &xkbCompPathStat) != 0) - { - #ifdef NX_TRANS_TEST - fprintf(stderr, "NXVerifyXkbCompPath: WARNING! Failed to stat xkbcomp path [%s].\n", - xkbCompPath); - #endif - - free(xkbCompPath); - - return 0; - } - - free(xkbCompPath); - - return 1; -} - -/* - * This function returns the directory - * containing the xkbcomp executable. - * The function will first try to locate - * the executable in the hardcoded path - * (the same path as the "base" xkb one) - * and, if the xkbcomp file couldn't be - * found, the function will not include - * an explicit path and will rely on the - * PATH environment to list the directory. - */ - -char *_NXGetXkbCompPath(const char *path) -{ - - char * xkbCompPath; - - /* - * Check the xkbcomp executable - * directory only once. - */ - - if (*_NXXkbCompPath != '\0') - { - return _NXXkbCompPath; - } - - xkbCompPath = _NXGetXkbBasePath(path); - - if (NXVerifyXkbCompPath(xkbCompPath) == 1) - { - if (strlen(xkbCompPath) + 1 > PATH_MAX) - { - #ifdef TEST - fprintf(stderr, "_NXGetXkbCompPath: WARNING! Maximum length of xkbcomp path exceeded.\n"); - #endif - - goto _NXGetXkbCompPathError; - } - - strcpy(_NXXkbCompPath, xkbCompPath); - - #ifdef TEST - fprintf(stderr, "_NXGetXkbCompPath: Using xkbcomp path [%s].\n", - _NXXkbCompPath); - #endif - - return _NXXkbCompPath; - } - - xkbCompPath = NX_ALT_XKBCOMP_PATH; - - if (NXVerifyXkbCompPath(xkbCompPath) == 1) - { - if (strlen(xkbCompPath) + 1 > PATH_MAX) - { - #ifdef TEST - fprintf(stderr, "_NXGetXkbCompPath: WARNING! Maximum length of xkbcomp path exceeded.\n"); - #endif - - goto _NXGetXkbCompPathError; - } - - strcpy(_NXXkbCompPath, xkbCompPath); - - #ifdef TEST - fprintf(stderr, "_NXGetXkbCompPath: Using NX xkbcomp path [%s].\n", - _NXXkbCompPath); - #endif - - return _NXXkbCompPath; - } - -_NXGetXkbCompPathError: - - if (strlen(path) + 1 > PATH_MAX) - { - #ifdef TEST - fprintf(stderr, "_NXGetXkbCompPath: WARNING! Maximum length of xkbcomp path exceeded.\n"); - #endif - } - - strcpy(_NXXkbCompPath, path); - - #ifdef TEST - fprintf(stderr, "_NXGetXkbCompPath: Using default xkbcomp path [%s].\n", - _NXXkbCompPath); - #endif - - return _NXXkbCompPath; -} - -#endif - static void OutputDirectory( char* outdir, @@ -547,24 +243,11 @@ char *cmd = NULL,file[PATH_MAX],xkm_output_dir[PATH_MAX],*map,*outFile; XkbEnsureSafeMapName(outFile); OutputDirectory(xkm_output_dir, sizeof(xkm_output_dir)); -#ifdef NXAGENT_SERVER - - if (_NXGetXkbCompPath(XkbBaseDirectory) != NULL) - { - -#else - if (XkbBaseDirectory!=NULL) { -#endif - -#ifdef NXAGENT_SERVER - char *xkbbasedir = _NXGetXkbBasePath(XkbBaseDirectory); - char *xkbbindir = _NXGetXkbCompPath(XkbBinDirectory); -#else char *xkbbasedir = XkbBaseDirectory; char *xkbbindir = XkbBinDirectory; -#endif + cmd = Xprintf("\"%s" PATHSEPARATOR "xkbcomp\" -w %d \"-R%s\" -xkm %s%s -em1 %s -emp %s -eml %s keymap/%s \"%s%s.xkm\"", xkbbindir, ((xkbDebugFlags<2)?1:((xkbDebugFlags>10)?10:(int)xkbDebugFlags)), @@ -642,12 +325,7 @@ char tmpname[PATH_MAX]; (void) mktemp(tmpname); #endif -#ifdef NXAGENT_SERVER - if (_NXGetXkbCompPath(XkbBaseDirectory)!=NULL) { -#else if (XkbBaseDirectory!=NULL) { -#endif - #ifndef WIN32 char *xkmfile = "-"; #else @@ -655,13 +333,8 @@ char tmpname[PATH_MAX]; for xkbcomp. xkbcomp does not read from stdin. */ char *xkmfile = tmpname; #endif -#ifdef NXAGENT_SERVER - char *xkbbasedir = _NXGetXkbBasePath(XkbBaseDirectory); - char *xkbbindir = _NXGetXkbCompPath(XkbBinDirectory); -#else char *xkbbasedir = XkbBaseDirectory; char *xkbbindir = XkbBinDirectory; -#endif buf = Xprintf( "\"%s" PATHSEPARATOR "xkbcomp\" -w %d \"-R%s\" -xkm \"%s\" -em1 %s -emp %s -eml %s \"%s%s.xkm\"", -- cgit v1.2.3 From eb07ed57bb9afdde7bf0f1e501ce08d5fd3de30e Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 5 Jul 2018 23:23:11 +0200 Subject: Keyboard.c: do not define own RLMVO defaults use the ones from xkb --- nx-X11/programs/Xserver/hw/nxagent/Keyboard.c | 99 ++------------------------- 1 file changed, 5 insertions(+), 94 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c index d943ec2c4..2ffdde1c2 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c @@ -135,25 +135,6 @@ extern Status XkbGetControls( #endif ); -#ifndef XKB_DFLT_RULES_FILE -#define XKB_DFLT_RULES_FILE "base" -#endif -#ifndef XKB_ALTS_RULES_FILE -#define XKB_ALTS_RULES_FILE "xorg" -#endif -#ifndef XKB_DFLT_KB_LAYOUT -#define XKB_DFLT_KB_LAYOUT "us" -#endif -#ifndef XKB_DFLT_KB_MODEL -#define XKB_DFLT_KB_MODEL "pc102" -#endif -#ifndef XKB_DFLT_KB_VARIANT -#define XKB_DFLT_KB_VARIANT NULL -#endif -#ifndef XKB_DFLT_KB_OPTIONS -#define XKB_DFLT_KB_OPTIONS NULL -#endif - extern int XkbDfltRepeatDelay; extern int XkbDfltRepeatInterval; @@ -180,8 +161,6 @@ XkbWrapperRec nxagentXkbWrapper; extern char *nxagentKeyboard; -static char *nxagentXkbGetRules(void); - unsigned int nxagentAltMetaMask; unsigned int nxagentAltMask; unsigned int nxagentMetaMask; @@ -481,73 +460,6 @@ static int nxagentRestoreKeyboardDeviceData(DeviceIntPtr devBackup, DeviceIntPtr static int nxagentFreeKeyboardDeviceData(DeviceIntPtr dev); -static char *nxagentXkbGetRules() -{ - int ret; - char *path; - struct stat buf; - - #ifdef TEST - fprintf(stderr, "nxagentXkbGetRules: XkbBaseDirectory [%s].\n", - XkbBaseDirectory); - #endif - - if (-1 == asprintf(&path, "%s/rules/%s", XkbBaseDirectory, XKB_DFLT_RULES_FILE)) - { - FatalError("nxagentXkbGetRules: malloc failed."); - } - - #ifdef TEST - fprintf(stderr, "nxagentXkbGetRules: checking rules file [%s]\n", path); - #endif - ret = stat(path, &buf); - - if (ret == 0) - { - free(path); - #ifdef TEST - fprintf(stderr, "nxagentXkbGetRules: returning default rules file [%s]\n", XKB_DFLT_RULES_FILE); - #endif - return XKB_DFLT_RULES_FILE; - } - - #ifdef TEST - fprintf(stderr, "nxagentXkbGetRules: WARNING! Failed to stat file [%s]: %s.\n", path, strerror(ret)); - #endif - - free(path); - path = NULL; - - if (-1 == asprintf(&path, "%s/rules/%s", XkbBaseDirectory, XKB_ALTS_RULES_FILE)) - { - FatalError("nxagentXkbGetRules: malloc failed."); - } - - #ifdef TEST - fprintf(stderr, "nxagentXkbGetRules: checking rules file [%s]\n", path); - #endif - ret = stat(path, &buf); - - if (ret == 0) - { - free(path); - #ifdef TEST - fprintf(stderr, "nxagentXkbGetRules: returning alternative rules file [%s]\n", XKB_ALTS_RULES_FILE); - #endif - return XKB_ALTS_RULES_FILE; - } - - #ifdef WARNING - fprintf(stderr, "nxagentXkbGetRules: WARNING! Failed to stat file [%s]: %s.\n", path, strerror(ret)); - #endif - - free(path); - #ifdef TEST - fprintf(stderr, "nxagentXkbGetRules: returning default rules file [%s]\n", XKB_DFLT_RULES_FILE); - #endif - return XKB_DFLT_RULES_FILE; -} - void nxagentBell(int volume, DeviceIntPtr pDev, void * ctrl, int cls) { XBell(nxagentDisplay, volume); @@ -843,8 +755,7 @@ XkbError: fprintf(stderr, "nxagentKeyboardProc: nxagentKeyboard is [%s].\n", nxagentKeyboard ? nxagentKeyboard : "NULL"); #endif - - rules = nxagentXkbGetRules(); + rules = NULL; /* use xkb default */ /* from nxagent changelog: @@ -901,8 +812,8 @@ XkbError: } else { - layout = XKB_DFLT_KB_LAYOUT; - model = XKB_DFLT_KB_MODEL; + layout = NULL; /* use xkb default */ + model = NULL; /* use xkb default */ #ifdef TEST fprintf(stderr, "nxagentKeyboardProc: Using default keyboard: model [%s] layout [%s].\n", @@ -910,8 +821,8 @@ XkbError: #endif } - variants = XKB_DFLT_KB_VARIANT; - options = XKB_DFLT_KB_OPTIONS; + variants = NULL; /* use xkb default */ + options = NULL; /* use xkb default */ #ifdef TEST fprintf(stderr, "nxagentKeyboardProc: Init XKB extension.\n"); -- cgit v1.2.3 From 4ed8145f7be80f162970e25cf960aa7d24b3dafb Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 6 Jul 2018 23:30:45 +0200 Subject: XKB: provide XKB defines via Imakefile --- nx-X11/programs/Xserver/xkb/Imakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nx-X11/programs/Xserver/xkb/Imakefile b/nx-X11/programs/Xserver/xkb/Imakefile index 21d631acd..93f18542a 100644 --- a/nx-X11/programs/Xserver/xkb/Imakefile +++ b/nx-X11/programs/Xserver/xkb/Imakefile @@ -40,7 +40,7 @@ XKB_DDXDEFS = XkbServerDefines LINTLIBS = ../dix/llib-ldix.ln ../os/llib-los.ln DEFINES = $(XKB_DDXDEFS) $(NX_DEFINES) -XKB_DEFINES = -DXKB_BASE_DIRECTORY=\"$(LIBDIR)/xkb\" $(XKB_DISABLE) +XKB_DEFINES = -DXKB_BASE_DIRECTORY=\"/usr/share/X11/xkb\" -DXKB_BIN_DIRECTORY=\"/usr/bin\" -DXKB_DFLT_RULES_FILE=\"base\" -DXKB_DFLT_KB_LAYOUT=\"us\" -DXKB_DFLT_KB_MODEL=\"pc102\" $(XKB_DISABLE) NormalLibraryObjectRule() NormalLibraryTarget(xkb,$(OBJS)) -- cgit v1.2.3 From 3fbef7da756b15640d1bd7828da68b5ddb0ca848 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Sat, 7 Jul 2018 23:51:27 +0200 Subject: Lift xkb to XORG-1.3.0.0 state --- nx-X11/programs/Xserver/xkb/xkbInit.c | 1 + nx-X11/programs/Xserver/xkb/xkbLEDs.c | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/nx-X11/programs/Xserver/xkb/xkbInit.c b/nx-X11/programs/Xserver/xkb/xkbInit.c index a45906568..ab457c7ce 100644 --- a/nx-X11/programs/Xserver/xkb/xkbInit.c +++ b/nx-X11/programs/Xserver/xkb/xkbInit.c @@ -107,6 +107,7 @@ typedef struct _SrvXkmInfo { char * XkbBaseDirectory= XKB_BASE_DIRECTORY; char * XkbBinDirectory= XKB_BIN_DIRECTORY; + static int XkbWantAccessX= 0; static XkbFileInfo * _XkbInitFileInfo= NULL; diff --git a/nx-X11/programs/Xserver/xkb/xkbLEDs.c b/nx-X11/programs/Xserver/xkb/xkbLEDs.c index 2383bdd99..0fccd0913 100644 --- a/nx-X11/programs/Xserver/xkb/xkbLEDs.c +++ b/nx-X11/programs/Xserver/xkb/xkbLEDs.c @@ -274,13 +274,13 @@ unsigned oldState; changes->indicators.state_changes|= affected; } - ed->reason|= (XkbXI_IndicatorStateMask&(~XkbXIUnsupported)); + ed->reason|= (XkbXI_IndicatorStateMask&(~XkbXI_KeyboardsMask)); ed->ledClass= sli->class; ed->ledID= sli->id; ed->ledsDefined= sli->namesPresent|sli->mapsPresent; ed->ledState= sli->effectiveState; - ed->unsupported|= XkbXIUnsupported&XkbXI_IndicatorStateMask; - ed->supported= XkbXI_AllFeaturesMask&(~XkbXIUnsupported); + ed->unsupported|= XkbXI_KeyboardsMask&XkbXI_IndicatorStateMask; + ed->supported= XkbXI_AllFeaturesMask&(~XkbXI_KeyboardsMask); if (changes!=&my_changes) changes= NULL; if (ed!=&my_ed) ed= NULL; -- cgit v1.2.3 From b891e5f6859298c3482067752c9e4b2fd19ed617 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 16 Jul 2018 22:07:26 +0200 Subject: Keyboard.c: always ask for remote XKB --- nx-X11/programs/Xserver/hw/nxagent/Keyboard.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c index 2ffdde1c2..103a817dd 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c @@ -693,6 +693,18 @@ N/A keySyms.mapWidth = mapWidth; keySyms.map = keymap; + if (XkbQueryExtension(nxagentDisplay, + &nxagentXkbInfo.Opcode, + &nxagentXkbInfo.EventBase, + &nxagentXkbInfo.ErrorBase, + &nxagentXkbInfo.MajorVersion, + &nxagentXkbInfo.MinorVersion) == 0) + { + ErrorF("Unable to initialize XKEYBOARD extension.\n"); + goto XkbError; + } + + #ifdef XKB /* @@ -828,18 +840,6 @@ XkbError: fprintf(stderr, "nxagentKeyboardProc: Init XKB extension.\n"); #endif - if (XkbQueryExtension(nxagentDisplay, - &nxagentXkbInfo.Opcode, - &nxagentXkbInfo.EventBase, - &nxagentXkbInfo.ErrorBase, - &nxagentXkbInfo.MajorVersion, - &nxagentXkbInfo.MinorVersion) == 0) - { - ErrorF("Unable to initialize XKEYBOARD extension.\n"); - - goto XkbError; - } - xkb = XkbGetKeyboard(nxagentDisplay, XkbGBN_AllComponentsMask, XkbUseCoreKbd); nxagentKeycodeConversionSetup(); -- cgit v1.2.3 From 6186383e70b56ba0782fae3c851779f2f079cbcd Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 16 Jul 2018 22:22:10 +0200 Subject: Keyboard.c: simplify RLMVO string handling --- nx-X11/programs/Xserver/hw/nxagent/Keyboard.c | 46 ++++++--------------------- 1 file changed, 9 insertions(+), 37 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c index 103a817dd..9c0fd0212 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c @@ -570,7 +570,6 @@ int nxagentKeyboardProc(DeviceIntPtr pDev, int onoff) int i, j; XKeyboardState values; char *model = NULL, *layout = NULL; - int free_model = 0, free_layout = 0; XkbDescPtr xkb = NULL; switch (onoff) @@ -726,16 +725,9 @@ XkbError: XkbFreeKeyboard(xkb, XkbAllComponentsMask, True); xkb = NULL; - if (free_model) - { - free_model = 0; - free(model); - } - if (free_layout) - { - free_layout = 0; - free(layout); - } + + free(model); + free(layout); #endif XGetKeyboardControl(nxagentDisplay, &values); @@ -757,7 +749,7 @@ XkbError: #ifdef XKB } else { /* if (noXkbExtension) */ XkbComponentNamesRec names = {0}; - char *rules, *variants, *options; + char *rules = NULL, *variants = NULL, *options = NULL; /* use xkb default */ #ifdef TEST fprintf(stderr, "nxagentKeyboardProc: Using XKB extension.\n"); @@ -767,8 +759,6 @@ XkbError: fprintf(stderr, "nxagentKeyboardProc: nxagentKeyboard is [%s].\n", nxagentKeyboard ? nxagentKeyboard : "NULL"); #endif - rules = NULL; /* use xkb default */ - /* from nxagent changelog: 2.0.22: @@ -791,11 +781,8 @@ XkbError: goto XkbError; } - free_model = 1; - model = strndup(nxagentKeyboard, i); - - free_layout = 1; - layout = strdup(&nxagentKeyboard[i + 1]); + model = strndup(nxagentKeyboard, i); + layout = strdup(&nxagentKeyboard[i + 1]); /* * There is no description for pc105 on Solaris. @@ -824,18 +811,12 @@ XkbError: } else { - layout = NULL; /* use xkb default */ - model = NULL; /* use xkb default */ - #ifdef TEST fprintf(stderr, "nxagentKeyboardProc: Using default keyboard: model [%s] layout [%s].\n", model, layout); #endif } - variants = NULL; /* use xkb default */ - options = NULL; /* use xkb default */ - #ifdef TEST fprintf(stderr, "nxagentKeyboardProc: Init XKB extension.\n"); #endif @@ -900,20 +881,11 @@ XkbEnd: NXShadowInitKeymap(&(pDev->key->curKeySyms)); } - if (free_model) - { - free_model = 0; - free(model); - } - - if (free_layout) - { - free_layout = 0; - free(layout); - } - XkbFreeKeyboard(xkb, XkbAllComponentsMask, True); xkb = NULL; + + free(model); + free(layout); } #endif -- cgit v1.2.3 From 1b05251a02f2fbac09fb267f0c7fcb411c7e0105 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 1 Nov 2018 14:46:54 +0100 Subject: Keyboard.c: simplify over-specific if --- nx-X11/programs/Xserver/hw/nxagent/Keyboard.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c index 9c0fd0212..65c4d20fe 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c @@ -869,8 +869,7 @@ XkbError: XkbInitKeyboardDeviceStruct((void *)pDev, &names, &keySyms, modmap, nxagentBell, nxagentChangeKeyboardControl); - if (!nxagentKeyboard || - (nxagentKeyboard && (strcmp(nxagentKeyboard, "query") == 0))) + if (!nxagentKeyboard || strcmp(nxagentKeyboard, "query") == 0) { goto XkbError; } -- cgit v1.2.3 From d8bbbcf29c3c0e43ce28d76e52e6a8ad9deeb90f Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 16 Jul 2018 22:23:05 +0200 Subject: Keyboard.c: guard XkbFreeKeyboard calls manpage does not tell us if NULL is valid --- nx-X11/programs/Xserver/hw/nxagent/Keyboard.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c index 65c4d20fe..84121c1db 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c @@ -723,8 +723,11 @@ XkbError: fprintf(stderr, "nxagentKeyboardProc: XKB error.\n"); #endif - XkbFreeKeyboard(xkb, XkbAllComponentsMask, True); - xkb = NULL; + if (xkb) + { + XkbFreeKeyboard(xkb, XkbAllComponentsMask, True); + xkb = NULL; + } free(model); free(layout); @@ -874,14 +877,16 @@ XkbError: goto XkbError; } -XkbEnd: if (nxagentOption(Shadow) == 1 && pDev && pDev->key) { NXShadowInitKeymap(&(pDev->key->curKeySyms)); } - XkbFreeKeyboard(xkb, XkbAllComponentsMask, True); - xkb = NULL; + if (xkb) + { + XkbFreeKeyboard(xkb, XkbAllComponentsMask, True); + xkb = NULL; + } free(model); free(layout); -- cgit v1.2.3 From 05e03b965855e13557745d25eabe63698cb61bc1 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 16 Jul 2018 22:23:56 +0200 Subject: Keyboard.c: greatly simplify the code in nxagentKeyboardProc most of the code was existing twice --- nx-X11/programs/Xserver/hw/nxagent/Keyboard.c | 44 ++++++++------------------- 1 file changed, 13 insertions(+), 31 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c index 84121c1db..ff23ba232 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c @@ -828,39 +828,16 @@ XkbError: nxagentKeycodeConversionSetup(); - if (xkb == NULL || xkb->geom == NULL) + if (xkb && xkb->geom) { - #ifdef TEST - fprintf(stderr, "nxagentKeyboardProc: No current keyboard.\n"); - if (xkb == NULL) - { - fprintf(stderr, "nxagentKeyboardProc: xkb is null.\n"); - } - else - { - fprintf(stderr, "nxagentKeyboardProc: xkb->geom is null.\n"); - } - fprintf(stderr, "nxagentKeyboardProc: Going to set rules and init device.\n"); - #endif - #ifdef DEBUG - fprintf(stderr, "nxagentKeyboardProc: Going to set rules and init device: " - "[rules='%s',model='%s',layout='%s',variants='%s',options='%s'].\n", - rules, model, layout, variants, options); - #endif - - XkbSetRulesDflts(rules, model, layout, variants, options); - XkbInitKeyboardDeviceStruct((void *)pDev, &names, &keySyms, modmap, - nxagentBell, nxagentChangeKeyboardControl); - - if (!nxagentKeyboard || strcmp(nxagentKeyboard, "query") == 0) - { - goto XkbError; - } - - goto XkbEnd; + XkbGetControls(nxagentDisplay, XkbAllControlsMask, xkb); } - - XkbGetControls(nxagentDisplay, XkbAllControlsMask, xkb); +#ifdef TEST + else + { + fprintf(stderr, "nxagentKeyboardProc: No current keyboard.\n"); + } +#endif #ifdef DEBUG fprintf(stderr, "nxagentKeyboardProc: Going to set rules and init device: " @@ -877,6 +854,11 @@ XkbError: goto XkbError; } + if (xkb && xkb->geom) + { + XkbDDXChangeControls(pDev, xkb->ctrls, xkb->ctrls); + } + if (nxagentOption(Shadow) == 1 && pDev && pDev->key) { NXShadowInitKeymap(&(pDev->key->curKeySyms)); -- cgit v1.2.3 From b8ae794e47cf2e23f7391856865d4e06c7a61fd1 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Wed, 18 Jul 2018 19:14:40 +0200 Subject: Keyboard.c: fix keyboard=query logic an empty nxagentKeyboard variable is no reason to fall back to no-XKB mode --- nx-X11/programs/Xserver/hw/nxagent/Keyboard.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c index ff23ba232..eea09a436 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c @@ -849,7 +849,7 @@ XkbError: XkbInitKeyboardDeviceStruct((void *)pDev, &names, &keySyms, modmap, nxagentBell, nxagentChangeKeyboardControl); - if (!nxagentKeyboard || strcmp(nxagentKeyboard, "query") == 0) + if (nxagentKeyboard && strcmp(nxagentKeyboard, "query") == 0) { goto XkbError; } -- cgit v1.2.3 From 59524cd062f87874f11d566a32836a97e8426382 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Wed, 18 Jul 2018 22:16:48 +0200 Subject: Keyboard.c: simplify even more: free stuff at one place --- nx-X11/programs/Xserver/hw/nxagent/Keyboard.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c index eea09a436..c2c36ad23 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c @@ -723,14 +723,6 @@ XkbError: fprintf(stderr, "nxagentKeyboardProc: XKB error.\n"); #endif - if (xkb) - { - XkbFreeKeyboard(xkb, XkbAllComponentsMask, True); - xkb = NULL; - } - - free(model); - free(layout); #endif XGetKeyboardControl(nxagentDisplay, &values); @@ -863,16 +855,16 @@ XkbError: { NXShadowInitKeymap(&(pDev->key->curKeySyms)); } + } - if (xkb) - { - XkbFreeKeyboard(xkb, XkbAllComponentsMask, True); - xkb = NULL; - } - - free(model); - free(layout); + if (xkb) + { + XkbFreeKeyboard(xkb, XkbAllComponentsMask, True); + xkb = NULL; } + + free(model); + free(layout); #endif #ifdef WATCH -- cgit v1.2.3 From 018b2d0c63505960ba82b4ca1fac7852ee3d5115 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Wed, 18 Jul 2018 23:09:32 +0200 Subject: XkbSendNames: fix use of uninitialised bytes valgrind error. Backported-to-nx-by: Ulrich Sibiller commit 8a34d7a8532c7ca013e67307f3baf200167abb92 Author: Ander Conselvan de Oliveira Date: Tue Feb 8 11:10:11 2011 +0200 XkbSendNames: fix use of uninitialised bytes valgrind error. ==537== Syscall param writev(vector[...]) points to uninitialised byte(s) ==537== at 0x4AB7154: writev (writev.c:51) ==537== by 0x8935B: _XSERVTransWritev (Xtrans.c:912) ==537== by 0x6C55F: FlushClient (io.c:924) ==537== by 0x6CCF3: WriteToClient (io.c:846) ==537== by 0xD51D3: XkbSendNames (xkb.c:3765) ==537== by 0xD8183: ProcXkbGetKbdByName (xkb.c:5825) ==537== by 0x27B7B: Dispatch (dispatch.c:432) ==537== by 0x205B7: main (main.c:291) ==537== Address 0x55899f2 is 154 bytes inside a block of size 1,896 alloc'd ==537== at 0x4834C48: malloc (vg_replace_malloc.c:236) ==537== by 0xD47AF: XkbSendNames (xkb.c:3642) ==537== by 0xD8183: ProcXkbGetKbdByName (xkb.c:5825) ==537== by 0x27B7B: Dispatch (dispatch.c:432) ==537== by 0x205B7: main (main.c:291) ==537== Uninitialised value was created by a heap allocation ==537== at 0x4834C48: malloc (vg_replace_malloc.c:236) ==537== by 0xD47AF: XkbSendNames (xkb.c:3642) ==537== by 0xD8183: ProcXkbGetKbdByName (xkb.c:5825) ==537== by 0x27B7B: Dispatch (dispatch.c:432) ==537== by 0x205B7: main (main.c:291) Signed-off-by: Peter Hutterer Reviewed-by: Oliver McFadden Signed-off-by: Ander Conselvan de Oliveira --- nx-X11/programs/Xserver/xkb/xkb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nx-X11/programs/Xserver/xkb/xkb.c b/nx-X11/programs/Xserver/xkb/xkb.c index 3de41c086..f601f04b7 100644 --- a/nx-X11/programs/Xserver/xkb/xkb.c +++ b/nx-X11/programs/Xserver/xkb/xkb.c @@ -3203,7 +3203,7 @@ char * desc; swapl(&rep->indicators); } - start = desc = (char *)malloc(length); + start = desc = (char *)calloc(1, length); if ( !start ) return BadAlloc; if (xkb->names) { -- cgit v1.2.3 From 69475953b37d23c77f977833f12cc696c955cd5f Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Wed, 18 Jul 2018 23:15:07 +0200 Subject: ProcXkbGetKbdByName: fix use of uninitialised bytes valgrind error. We have fixed that (independendly) before, but missed one line. Backported-to-nx-by: Ulrich Sibiller commit 85f9017393c9bb19553e9afcf554673a44a09993 Author: Ander Conselvan de Oliveira Date: Tue Feb 8 11:10:10 2011 +0200 ProcXkbGetXkbByName: fix use of uninitialised bytes valgrind error. ==9999== Syscall param writev(vector[...]) points to uninitialised byte(s) ==9999== at 0x4AB5154: writev (writev.c:51) ==9999== by 0x7C7C3: _XSERVTransWritev (Xtrans.c:912) ==9999== by 0x61C8B: FlushClient (io.c:924) ==9999== by 0x62423: WriteToClient (io.c:846) ==9999== by 0xCE39B: XkbSendMap (xkb.c:1408) ==9999== by 0xD247B: ProcXkbGetKbdByName (xkb.c:5814) ==9999== by 0x4AB53: Dispatch (dispatch.c:432) ==9999== by 0x205BF: main (main.c:291) ==9999== Address 0x557eb68 is 40 bytes inside a block of size 4,096 alloc'd ==9999== at 0x48334A4: calloc (vg_replace_malloc.c:467) ==9999== by 0x62567: WriteToClient (io.c:1065) ==9999== by 0x452EB: ProcEstablishConnection (dispatch.c:3685) ==9999== by 0x4AB53: Dispatch (dispatch.c:432) ==9999== by 0x205BF: main (main.c:291) ==9999== Uninitialised value was created by a stack allocation ==9999== at 0xD1910: ProcXkbGetKbdByName (xkb.c:5559) Signed-off-by: Peter Hutterer Reviewed-by: Oliver McFadden Signed-off-by: Ander Conselvan de Oliveira --- nx-X11/programs/Xserver/xkb/xkb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nx-X11/programs/Xserver/xkb/xkb.c b/nx-X11/programs/Xserver/xkb/xkb.c index f601f04b7..e11d7e26b 100644 --- a/nx-X11/programs/Xserver/xkb/xkb.c +++ b/nx-X11/programs/Xserver/xkb/xkb.c @@ -5018,7 +5018,7 @@ ProcXkbGetKbdByName(ClientPtr client) xkbGetIndicatorMapReply irep = {0}; xkbGetNamesReply nrep = {0}; xkbGetGeometryReply grep = {0}; - XkbComponentNamesRec names; + XkbComponentNamesRec names = {0}; XkbDescPtr xkb; unsigned char * str; char mapFile[PATH_MAX]; -- cgit v1.2.3 From 6625e78c1292f2dc03329e55bbc33537cc8ee569 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Wed, 18 Jul 2018 23:26:10 +0200 Subject: XKB: Fix garbage initialization commit 8311cd5f89ca6781842bb24671b8122cdf8be148 Author: Jeremy Huddleston Date: Tue Mar 23 10:37:36 2010 -0700 XKB: Fix garbage initialization XkbEnableDisableControls set extra garbage bits on the xkbControlsNotify changedControls mask because it was uninitialized on the stack. Found by clang Signed-off-by: Jeremy Huddleston Signed-off-by: Peter Hutterer Backported-to-nx-by: Ulrich Sibiller --- nx-X11/programs/Xserver/xkb/xkbUtils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nx-X11/programs/Xserver/xkb/xkbUtils.c b/nx-X11/programs/Xserver/xkb/xkbUtils.c index c97a54bf4..028f32454 100644 --- a/nx-X11/programs/Xserver/xkb/xkbUtils.c +++ b/nx-X11/programs/Xserver/xkb/xkbUtils.c @@ -763,7 +763,7 @@ XkbSrvLedInfoPtr sli; if (cause!=NULL) { xkbControlsNotify cn; cn.numGroups= ctrls->num_groups; - cn.changedControls|= XkbControlsEnabledMask; + cn.changedControls= XkbControlsEnabledMask; cn.enabledControls= ctrls->enabled_ctrls; cn.enabledControlChanges= (ctrls->enabled_ctrls^old); cn.keycode= cause->kc; -- cgit v1.2.3 From 7487d7fa2dbc69fe39f81dd5b3e9a1a32ee7a2e0 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Wed, 18 Jul 2018 23:50:28 +0200 Subject: XKB: Fix logic error commit 6aef4e96affcc26b9415c6bc9c9bebb5af05a1a7 Author: Daniel Stone Date: Sat Jan 17 13:42:46 2009 +0200 XKB: Fix logic error Use logical or instead of bitwise or. Signed-off-by: Daniel Stone Signed-off-by: Peter Hutterer Backported-to-nx-by: Ulrich Sibiller --- nx-X11/programs/Xserver/xkb/xkbAccessX.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nx-X11/programs/Xserver/xkb/xkbAccessX.c b/nx-X11/programs/Xserver/xkb/xkbAccessX.c index cfd42334c..dd07713b8 100644 --- a/nx-X11/programs/Xserver/xkb/xkbAccessX.c +++ b/nx-X11/programs/Xserver/xkb/xkbAccessX.c @@ -607,7 +607,7 @@ Bool ignoreKeyEvent = FALSE; ev.keycode= key; ev.slowKeysDelay= ctrls->slow_keys_delay; ev.debounceDelay= ctrls->debounce_delay; - if (BitIsOn(keybd->key->down,key) | (xkbi->mouseKey == key)) { + if (BitIsOn(keybd->key->down,key) || (xkbi->mouseKey == key)) { ev.detail= XkbAXN_SKRelease; beep_type= _BEEP_SLOW_RELEASE; } -- cgit v1.2.3 From 3c1b1efad2ca42154789f09e2519630c5471ed41 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Wed, 18 Jul 2018 23:54:46 +0200 Subject: XKB: Remove unused DDX functions commit 7c4c00649cae855e141ec9a3667bfe399e3156d0 Author: Daniel Stone Date: Thu Jan 1 05:25:52 2009 +1100 XKB: Remove unused DDX functions They were complete no-ops anyway. Signed-off-by: Daniel Stone Signed-off-by: Peter Hutterer Backported-to-nx-by: Ulrich Sibiller --- nx-X11/programs/Xserver/xkb/Imakefile | 8 ++--- nx-X11/programs/Xserver/xkb/ddxInit.c | 45 ---------------------------- nx-X11/programs/Xserver/xkb/ddxKeyClick.c | 49 ------------------------------- nx-X11/programs/Xserver/xkb/xkbAccessX.c | 4 +-- nx-X11/programs/Xserver/xkb/xkbInit.c | 2 -- 5 files changed, 5 insertions(+), 103 deletions(-) delete mode 100644 nx-X11/programs/Xserver/xkb/ddxInit.c delete mode 100644 nx-X11/programs/Xserver/xkb/ddxKeyClick.c diff --git a/nx-X11/programs/Xserver/xkb/Imakefile b/nx-X11/programs/Xserver/xkb/Imakefile index 93f18542a..c73e4efd5 100644 --- a/nx-X11/programs/Xserver/xkb/Imakefile +++ b/nx-X11/programs/Xserver/xkb/Imakefile @@ -18,11 +18,11 @@ XKB_DDXDEFS = XkbServerDefines NX_DEFINES = -DNXAGENT_SERVER #endif - DDX_SRCS = ddxBeep.c ddxCtrls.c ddxFakeBtn.c ddxFakeMtn.c ddxInit.c \ - ddxKeyClick.c ddxKillSrv.c ddxLEDs.c ddxVT.c ddxLoad.c \ + DDX_SRCS = ddxBeep.c ddxCtrls.c ddxFakeBtn.c ddxFakeMtn.c \ + ddxKillSrv.c ddxLEDs.c ddxVT.c ddxLoad.c \ ddxList.c ddxDevBtn.c ddxPrivate.c - DDX_OBJS = ddxBeep.o ddxCtrls.o ddxFakeBtn.o ddxFakeMtn.o ddxInit.o \ - ddxKeyClick.o ddxKillSrv.o ddxLEDs.o ddxVT.o ddxLoad.o \ + DDX_OBJS = ddxBeep.o ddxCtrls.o ddxFakeBtn.o ddxFakeMtn.o \ + ddxKillSrv.o ddxLEDs.o ddxVT.o ddxLoad.o \ ddxList.o ddxDevBtn.o ddxPrivate.o SRCS = xkb.c xkbUtils.c xkbEvents.c xkbAccessX.c xkbSwap.c \ xkbLEDs.c xkbInit.c xkbActions.c xkbPrKeyEv.c \ diff --git a/nx-X11/programs/Xserver/xkb/ddxInit.c b/nx-X11/programs/Xserver/xkb/ddxInit.c deleted file mode 100644 index 18e5e6a45..000000000 --- a/nx-X11/programs/Xserver/xkb/ddxInit.c +++ /dev/null @@ -1,45 +0,0 @@ -/************************************************************ -Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc. - -Permission to use, copy, modify, and distribute this -software and its documentation for any purpose and without -fee is hereby granted, provided that the above copyright -notice appear in all copies and that both that copyright -notice and this permission notice appear in supporting -documentation, and that the name of Silicon Graphics not be -used in advertising or publicity pertaining to distribution -of the software without specific prior written permission. -Silicon Graphics makes no representation about the suitability -of this software for any purpose. It is provided "as is" -without any express or implied warranty. - -SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS -SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON -GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL -DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, -DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH -THE USE OR PERFORMANCE OF THIS SOFTWARE. - -********************************************************/ - -#ifdef HAVE_DIX_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include "inputstr.h" -#include "scrnintstr.h" -#include "windowstr.h" -#include -#include - -int -XkbDDXInitDevice(DeviceIntPtr dev) -{ - return 1; -} diff --git a/nx-X11/programs/Xserver/xkb/ddxKeyClick.c b/nx-X11/programs/Xserver/xkb/ddxKeyClick.c deleted file mode 100644 index ddc34b0fd..000000000 --- a/nx-X11/programs/Xserver/xkb/ddxKeyClick.c +++ /dev/null @@ -1,49 +0,0 @@ -/************************************************************ -Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc. - -Permission to use, copy, modify, and distribute this -software and its documentation for any purpose and without -fee is hereby granted, provided that the above copyright -notice appear in all copies and that both that copyright -notice and this permission notice appear in supporting -documentation, and that the name of Silicon Graphics not be -used in advertising or publicity pertaining to distribution -of the software without specific prior written permission. -Silicon Graphics makes no representation about the suitability -of this software for any purpose. It is provided "as is" -without any express or implied warranty. - -SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS -SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON -GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL -DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, -DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH -THE USE OR PERFORMANCE OF THIS SOFTWARE. - -********************************************************/ - -#ifdef HAVE_DIX_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include "inputstr.h" -#include "scrnintstr.h" -#include "windowstr.h" -#include -#include - -void -XkbDDXKeyClick(DeviceIntPtr pXDev,int keycode,int synthetic) -{ -#ifdef DEBUG - if (xkbDebugFlags) - ErrorF("Click.\n"); -#endif - return; -} diff --git a/nx-X11/programs/Xserver/xkb/xkbAccessX.c b/nx-X11/programs/Xserver/xkb/xkbAccessX.c index dd07713b8..5d9917d2b 100644 --- a/nx-X11/programs/Xserver/xkb/xkbAccessX.c +++ b/nx-X11/programs/Xserver/xkb/xkbAccessX.c @@ -132,9 +132,7 @@ xEvent xE; } #endif - if (_XkbIsPressEvent(type)) - XkbDDXKeyClick(keybd,keyCode,TRUE); - else if (isRepeat) + if (!_XkbIsPressEvent(type) && isRepeat) XkbLastRepeatEvent= (void *)&xE; XkbProcessKeyboardEvent(&xE,keybd,1L); XkbLastRepeatEvent= NULL; diff --git a/nx-X11/programs/Xserver/xkb/xkbInit.c b/nx-X11/programs/Xserver/xkb/xkbInit.c index ab457c7ce..2f7fa475d 100644 --- a/nx-X11/programs/Xserver/xkb/xkbInit.c +++ b/nx-X11/programs/Xserver/xkb/xkbInit.c @@ -543,8 +543,6 @@ XkbEventCauseRec cause; XkbInitIndicatorMap(xkbi,&file); - XkbDDXInitDevice(pXDev); - if (!(file.xkbinfo.defined&XkmSymbolsMask)) { XkbUpdateKeyTypesFromCore(pXDev,xkb->min_key_code,XkbNumKeys(xkb), &changes); -- cgit v1.2.3 From 1ca0aee93d5ab4f4e95f78a1935c7763931f0182 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Wed, 25 Jul 2018 22:27:47 +0200 Subject: Event.c: improve DEBUG output --- nx-X11/programs/Xserver/hw/nxagent/Events.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Events.c b/nx-X11/programs/Xserver/hw/nxagent/Events.c index 4c85145a9..5281b4b5c 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Events.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Events.c @@ -2891,9 +2891,21 @@ int nxagentHandleXFixesSelectionNotify(XEvent *X) XFixesSelectionEvent *xfixesEvent = (XFixesSelectionEvent *) X; - if (nxagentXFixesInfo.Initialized == 0 || - xfixesEvent -> type != (nxagentXFixesInfo.EventBase + XFixesSelectionNotify)) - return 0; + if (nxagentXFixesInfo.Initialized == 0) + { + #ifdef DEBUG + fprintf(stderr, "nxagentHandleXFixesSelectionNotify: XFixes not initialized - doing nothing.\n"); + #endif + return 0; + } + + if (xfixesEvent -> type != (nxagentXFixesInfo.EventBase + XFixesSelectionNotify)) + { + #ifdef DEBUG + fprintf(stderr, "nxagentHandleXFixesSelectionNotify: event type is [%d] - doing nothing.\n", xfixesEvent->type); + #endif + return 0; + } #ifdef TEST fprintf(stderr, "nxagentHandleXFixesSelectionNotify: Handling event.\n"); -- cgit v1.2.3 From 824b629732ed90e6040790eb07fe8271d5fb8fb3 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Wed, 25 Jul 2018 22:39:17 +0200 Subject: XKB: Fix size_syms calculation bug Backported from Xorg: commit f292de2ef13dc994a38029cee9e2642576893332 Author: Daniel Stone Date: Wed Mar 21 02:04:12 2007 +0200 XKB: Fix size_syms calculation bug Apparently it needed to be nSyms*15/10, not *12/10; make it match the other allocation code. Backported-to-nx-by: Ulrich Sibiller --- nx-X11/programs/Xserver/xkb/XKBMAlloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nx-X11/programs/Xserver/xkb/XKBMAlloc.c b/nx-X11/programs/Xserver/xkb/XKBMAlloc.c index 100e827b9..178d4153c 100644 --- a/nx-X11/programs/Xserver/xkb/XKBMAlloc.c +++ b/nx-X11/programs/Xserver/xkb/XKBMAlloc.c @@ -396,7 +396,7 @@ KeyCode matchingKeys[XkbMaxKeyCount],nMatchingKeys; } if (nResize>0) { int nextMatch; - xkb->map->size_syms= (nTotal*12)/10; + xkb->map->size_syms= (nTotal*15)/10; newSyms = _XkbTypedCalloc(xkb->map->size_syms,KeySym); if (newSyms==NULL) return BadAlloc; -- cgit v1.2.3 From f23189e7392254c9458bf76504920cb868360e40 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 25 Oct 2018 00:46:12 +0200 Subject: Make: Automatically determine xkb dir --- Makefile | 17 +++++++++++++---- debian/control | 1 + nx-X11/config/cf/Imake.tmpl | 8 ++++++++ nx-X11/programs/Xserver/xkb/Imakefile | 2 +- nx-libs.spec | 2 ++ 5 files changed, 25 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 38a13c894..fc094f703 100644 --- a/Makefile +++ b/Makefile @@ -33,6 +33,15 @@ IMAKE_FONT_DEFINES ?= $(shell pkg-config --modversion xfont2 1>/dev/null 2>/dev/ # Support older libXext versions. XEXT_EXTRA_DEFINES ?= $(shell pkg-config --exists 'xextproto < 7.1.0' 1>/dev/null 2>/dev/null && echo "-DLEGACY_XEXT_PROTO") +# check if the xkbcomp devel pkg is available - we need it for the next step +ifneq ($(shell pkg-config --exists xkbcomp && echo yes), yes) + $(error required xkbcomp devel package missing) +endif + +# the system's directory with the xkb data files (this needs to be +# independent of Imake's ProjectRoot or the configure prefix.) +XKB_SYS_DEFINES ?= -DSystemXkbConfigDir=$(shell pkg-config xkbcomp --variable=xkbconfigdir) -DSystemXkbBinDir=$(shell pkg-config xkbcomp --variable=prefix)/bin + IMAKE_DEFINES ?= NX_VERSION_MAJOR=$(shell ./version.sh 1) @@ -100,7 +109,7 @@ version: build-env: version # prepare Makefiles and the nx-X11 symlinking magic - ${MAKE} -j1 -C nx-X11 BuildIncludes FONT_DEFINES="$(FONT_DEFINES)" XEXT_EXTRA_DEFINES="$(XEXT_EXTRA_DEFINES)" IMAKE_DEFINES="$(IMAKE_DEFINES) $(IMAKE_FONT_DEFINES)" + ${MAKE} -j1 -C nx-X11 BuildIncludes FONT_DEFINES="$(FONT_DEFINES)" XEXT_EXTRA_DEFINES="$(XEXT_EXTRA_DEFINES)" IMAKE_DEFINES="$(IMAKE_DEFINES) $(IMAKE_FONT_DEFINES) $(XKB_SYS_DEFINES)" # set up environment for libNX_X11 build (X11 header files) mkdir -p nx-X11/exports/include/nx-X11/ @@ -125,7 +134,7 @@ clean-env: version [ -d exports/include/nx-X11/Xtrans ] && $(RM_DIR) exports/include/nx-X11/Xtrans/ || : [ -d exports/include/nx-X11/ ] && $(RM_DIR) exports/include/nx-X11/ || : - ${MAKE} -j1 -C nx-X11 clean FONT_DEFINES="$(FONT_DEFINES)" XEXT_EXTRA_DEFINES="$(XEXT_EXTRA_DEFINES)" IMAKE_DEFINES="$(IMAKE_DEFINES) $(IMAKE_FONT_DEFINES)" + ${MAKE} -j1 -C nx-X11 clean FONT_DEFINES="$(FONT_DEFINES)" XEXT_EXTRA_DEFINES="$(XEXT_EXTRA_DEFINES)" IMAKE_DEFINES="$(IMAKE_DEFINES) $(IMAKE_FONT_DEFINES) $(XKB_SYS_DEFINES)" build-lite: cd nxcomp && autoreconf -vfsi && (${CONFIGURE}) && ${MAKE} @@ -149,8 +158,8 @@ build-full: build-env # build nxagent fourth ./mesa-quilt push -a - ${MAKE} -j1 -C nx-X11 BuildDependsOnly FONT_DEFINES="$(FONT_DEFINES)" XEXT_EXTRA_DEFINES="$(XEXT_EXTRA_DEFINES)" IMAKE_DEFINES="$(IMAKE_DEFINES) $(IMAKE_FONT_DEFINES)" - ${MAKE} -C nx-X11 World USRLIBDIR="$(USRLIBDIR)" SHLIBDIR="$(SHLIBDIR)" FONT_DEFINES="$(FONT_DEFINES)" XFONTLIB="$(XFONTLIB)" XEXT_EXTRA_DEFINES="$(XEXT_EXTRA_DEFINES)" IMAKE_DEFINES="$(IMAKE_DEFINES) $(IMAKE_FONT_DEFINES)" + ${MAKE} -j1 -C nx-X11 BuildDependsOnly FONT_DEFINES="$(FONT_DEFINES)" XEXT_EXTRA_DEFINES="$(XEXT_EXTRA_DEFINES)" IMAKE_DEFINES="$(IMAKE_DEFINES) $(IMAKE_FONT_DEFINES) $(XKB_SYS_DEFINES)" + ${MAKE} -C nx-X11 World USRLIBDIR="$(USRLIBDIR)" SHLIBDIR="$(SHLIBDIR)" FONT_DEFINES="$(FONT_DEFINES)" XFONTLIB="$(XFONTLIB)" XEXT_EXTRA_DEFINES="$(XEXT_EXTRA_DEFINES)" IMAKE_DEFINES="$(IMAKE_DEFINES) $(IMAKE_FONT_DEFINES) $(XKB_SYS_DEFINES)" # build nxproxy fifth cd nxproxy && autoreconf -vfsi && (${CONFIGURE}) && ${MAKE} diff --git a/debian/control b/debian/control index aa41ba959..6d3607833 100644 --- a/debian/control +++ b/debian/control @@ -27,6 +27,7 @@ Build-Depends: libxtst-dev, pkg-config, quilt (>= 0.46-7~), + x11-xkb-utils, x11proto-core-dev, xutils-dev, zlib1g-dev, diff --git a/nx-X11/config/cf/Imake.tmpl b/nx-X11/config/cf/Imake.tmpl index e202dabce..ddd587ec6 100644 --- a/nx-X11/config/cf/Imake.tmpl +++ b/nx-X11/config/cf/Imake.tmpl @@ -784,6 +784,12 @@ TCLIBDIR = TclLibDir #ifndef SystemUsrIncDir #define SystemUsrIncDir /usr/include #endif +#ifndef SystemXkbConfigDir +#define SystemXkbConfigDir /usr/share/X11/xkb +#endif +#ifndef SystemXkbBinDir +#define SystemXkbBinDir /usr/bin +#endif #ifndef ShLibDir #define ShLibDir UsrLibDir @@ -1660,6 +1666,8 @@ TCLIBDIR = TclLibDir VARLIBDIR = VarLibDir /* xdm runtime files */ SYSTEMUSRLIBDIR = SystemUsrLibDir /* system's "/usr/lib" */ SYSTEMUSRINCDIR = SystemUsrIncDir /* system's "/usr/include" */ + SYSTEMXKBCONFDIR = SystemXkbConfigDir /* system's "/usr/share/xkb" */ + SYSTEMXKBBINDIR = SystemXkbBinDir /* system's "/usr/bin" */ SHLIBDIR = ShLibDir /* shared libraries */ LINTLIBDIR = LintlibDir /* lint libraries */ MANPATH = ManPath /* top of manual page tree */ diff --git a/nx-X11/programs/Xserver/xkb/Imakefile b/nx-X11/programs/Xserver/xkb/Imakefile index c73e4efd5..3725b2562 100644 --- a/nx-X11/programs/Xserver/xkb/Imakefile +++ b/nx-X11/programs/Xserver/xkb/Imakefile @@ -40,7 +40,7 @@ XKB_DDXDEFS = XkbServerDefines LINTLIBS = ../dix/llib-ldix.ln ../os/llib-los.ln DEFINES = $(XKB_DDXDEFS) $(NX_DEFINES) -XKB_DEFINES = -DXKB_BASE_DIRECTORY=\"/usr/share/X11/xkb\" -DXKB_BIN_DIRECTORY=\"/usr/bin\" -DXKB_DFLT_RULES_FILE=\"base\" -DXKB_DFLT_KB_LAYOUT=\"us\" -DXKB_DFLT_KB_MODEL=\"pc102\" $(XKB_DISABLE) +XKB_DEFINES = -DXKB_BASE_DIRECTORY=\"$(SYSTEMXKBCONFDIR)\" -DXKB_BIN_DIRECTORY=\"$(SYSTEMXKBBINDIR)\" -DXKB_DFLT_RULES_FILE=\"base\" -DXKB_DFLT_KB_LAYOUT=\"us\" -DXKB_DFLT_KB_MODEL=\"pc102\" $(XKB_DISABLE) NormalLibraryObjectRule() NormalLibraryTarget(xkb,$(OBJS)) diff --git a/nx-libs.spec b/nx-libs.spec index b268f12bf..396ff2323 100644 --- a/nx-libs.spec +++ b/nx-libs.spec @@ -32,6 +32,8 @@ BuildRequires: pkgconfig %if 0%{?suse_version} && 0%{?suse_version} < 1210 BuildRequires: xorg-x11-util-devel %else +# we need xkbcomp.pc +BuildRequires: xorg-x11-xkb-utils-devel BuildRequires: imake %endif -- cgit v1.2.3 From 90b83a79e6aed4e54ac29d022adf16be6869f054 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 29 Oct 2018 23:34:10 +0100 Subject: xkb: Fix memory leak if opening file fails Author: Pauli Nieminen Date: Thu Jul 22 11:33:33 2010 +0300 xkb: Fix memory leak if opening file fails If fopen fails pointer in buf would be overwriten with a new pointer. Signed-off-by: Pauli Nieminen Reviewed-by: Peter Hutterer Backported-to-NX-by: Ulrich Sibiller --- nx-X11/programs/Xserver/xkb/ddxList.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nx-X11/programs/Xserver/xkb/ddxList.c b/nx-X11/programs/Xserver/xkb/ddxList.c index e48e28da4..e751b6b24 100644 --- a/nx-X11/programs/Xserver/xkb/ddxList.c +++ b/nx-X11/programs/Xserver/xkb/ddxList.c @@ -167,6 +167,7 @@ char tmpname[PATH_MAX]; } if (!in) { haveDir= False; + free(buf); buf = Xprintf( "'%s/xkbcomp' '-R%s/%s' -w %ld -l -vlfhpR '%s'" W32_tmparg, XkbBinDirectory,XkbBaseDirectory,componentDirs[what],(long) @@ -182,6 +183,7 @@ char tmpname[PATH_MAX]; } if (!in) { haveDir= False; + free(buf); buf = Xprintf( "xkbcomp -R%s -w %ld -l -vlfhpR '%s'" W32_tmparg, componentDirs[what],(long) -- cgit v1.2.3 From b01e29efffafe9f426eb88ba400e2fa24de548aa Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 29 Oct 2018 23:39:03 +0100 Subject: xkb: Don't check for NULL before calling free Author: Pauli Nieminen Date: Thu Jul 22 11:34:54 2010 +0300 xkb: Don't check for NULL before calling free Signed-off-by: Pauli Nieminen Reviewed-by: Peter Hutterer Backported-to-NX-by: Ulrich Sibiller --- nx-X11/programs/Xserver/xkb/ddxList.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/nx-X11/programs/Xserver/xkb/ddxList.c b/nx-X11/programs/Xserver/xkb/ddxList.c index e751b6b24..5466cff37 100644 --- a/nx-X11/programs/Xserver/xkb/ddxList.c +++ b/nx-X11/programs/Xserver/xkb/ddxList.c @@ -209,8 +209,7 @@ char tmpname[PATH_MAX]; } if (!in) { - if (buf != NULL) - free (buf); + free (buf); #ifdef WIN32 unlink(tmpname); #endif @@ -276,8 +275,7 @@ char tmpname[PATH_MAX]; fclose(in); unlink(tmpname); #endif - if (buf != NULL) - free (buf); + free (buf); return status; } -- cgit v1.2.3 From b09a72b08c7effeac42652f087f0b8f16bc74763 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 30 Oct 2018 00:00:45 +0100 Subject: Convert existing Xprintf style calls to asprintf style This commit + some more adaption in ddxLoad.c which where no longer present when Alan did the patch. However, our code still has them: Author: Alan Coopersmith Date: Sat Nov 27 20:09:04 2010 -0800 Convert existing Xprintf style calls to asprintf style Signed-off-by: Alan Coopersmith Reviewed-by: Jeremy Huddleston Reviewed-by: Mikhail Gusarov Backported-to-NX-by: Ulrich Sibiller --- nx-X11/programs/Xserver/xkb/ddxList.c | 36 +++++++++++++++++++++++------------ nx-X11/programs/Xserver/xkb/ddxLoad.c | 22 ++++++++++++--------- 2 files changed, 37 insertions(+), 21 deletions(-) diff --git a/nx-X11/programs/Xserver/xkb/ddxList.c b/nx-X11/programs/Xserver/xkb/ddxList.c index 5466cff37..cc95c8603 100644 --- a/nx-X11/programs/Xserver/xkb/ddxList.c +++ b/nx-X11/programs/Xserver/xkb/ddxList.c @@ -162,34 +162,46 @@ char tmpname[PATH_MAX]; #endif if (XkbBaseDirectory!=NULL) { if ((list->pattern[what][0]=='*')&&(list->pattern[what][1]=='\0')) { - buf = Xprintf("%s/%s.dir",XkbBaseDirectory,componentDirs[what]); - in= fopen(buf,"r"); + if (asprintf(&buf, "%s/%s.dir", XkbBaseDirectory, + componentDirs[what]) == -1) + buf = NULL; + else + in = fopen(buf,"r"); } if (!in) { haveDir= False; free(buf); - buf = Xprintf( + if (asprintf + (&buf, "'%s/xkbcomp' '-R%s/%s' -w %ld -l -vlfhpR '%s'" W32_tmparg, - XkbBinDirectory,XkbBaseDirectory,componentDirs[what],(long) - ((xkbDebugFlags<2)?1:((xkbDebugFlags>10)?10:xkbDebugFlags)), + XkbBinDirectory, XkbBaseDirectory, componentDirs[what], + (long) ((xkbDebugFlags < 2) ? 1 : + ((xkbDebugFlags > 10) ? 10 : xkbDebugFlags)), file W32_tmpfile - ); + ) == -1) + buf = NULL; } } else { if ((list->pattern[what][0]=='*')&&(list->pattern[what][1]=='\0')) { - buf = Xprintf("%s.dir",componentDirs[what]); - in= fopen(buf,"r"); + if (asprintf(&buf, "%s.dir", componentDirs[what]) == -1) + buf = NULL; + else + in = fopen(buf,"r"); + buf = NULL; } if (!in) { haveDir= False; free(buf); - buf = Xprintf( + if (asprintf + (&buf, "xkbcomp -R%s -w %ld -l -vlfhpR '%s'" W32_tmparg, - componentDirs[what],(long) - ((xkbDebugFlags<2)?1:((xkbDebugFlags>10)?10:xkbDebugFlags)), + componentDirs[what], + (long) ((xkbDebugFlags < 2) ? 1 : + ((xkbDebugFlags > 10) ? 10 : xkbDebugFlags)), file W32_tmpfile - ); + ) == -1) + buf = NULL; } } status= Success; diff --git a/nx-X11/programs/Xserver/xkb/ddxLoad.c b/nx-X11/programs/Xserver/xkb/ddxLoad.c index fca0cd62f..d63512846 100644 --- a/nx-X11/programs/Xserver/xkb/ddxLoad.c +++ b/nx-X11/programs/Xserver/xkb/ddxLoad.c @@ -248,19 +248,21 @@ char *cmd = NULL,file[PATH_MAX],xkm_output_dir[PATH_MAX],*map,*outFile; char *xkbbasedir = XkbBaseDirectory; char *xkbbindir = XkbBinDirectory; - cmd = Xprintf("\"%s" PATHSEPARATOR "xkbcomp\" -w %d \"-R%s\" -xkm %s%s -em1 %s -emp %s -eml %s keymap/%s \"%s%s.xkm\"", + if (asprintf(&cmd,"\"%s" PATHSEPARATOR "xkbcomp\" -w %d \"-R%s\" -xkm %s%s -em1 %s -emp %s -eml %s keymap/%s \"%s%s.xkm\"", xkbbindir, ((xkbDebugFlags<2)?1:((xkbDebugFlags>10)?10:(int)xkbDebugFlags)), xkbbasedir,(map?"-m ":""),(map?map:""), PRE_ERROR_MSG,ERROR_PREFIX,POST_ERROR_MSG1,file, - xkm_output_dir,outFile); + xkm_output_dir,outFile) == -1) + cmd = NULL; } else { - cmd = Xprintf("xkbcomp -w %d -xkm %s%s -em1 %s -emp %s -eml %s keymap/%s \"%s%s.xkm\"", + if (asprintf(&cmd, "xkbcomp -w %d -xkm %s%s -em1 %s -emp %s -eml %s keymap/%s \"%s%s.xkm\"", ((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); + xkm_output_dir,outFile) == -1) + cmd = NULL; } #ifdef DEBUG if (xkbDebugFlags) { @@ -336,13 +338,14 @@ char tmpname[PATH_MAX]; char *xkbbasedir = XkbBaseDirectory; char *xkbbindir = XkbBinDirectory; - buf = Xprintf( - "\"%s" PATHSEPARATOR "xkbcomp\" -w %d \"-R%s\" -xkm \"%s\" -em1 %s -emp %s -eml %s \"%s%s.xkm\"", + if (asprintf(&buf, + "\"%s" PATHSEPARATOR "xkbcomp\" -w %d \"-R%s\" -xkm \"%s\" -em1 %s -emp %s -eml %s \"%s%s.xkm\"", xkbbindir, ((xkbDebugFlags<2)?1:((xkbDebugFlags>10)?10:(int)xkbDebugFlags)), xkbbasedir, xkmfile, PRE_ERROR_MSG,ERROR_PREFIX,POST_ERROR_MSG1, - xkm_output_dir,keymap); + xkm_output_dir,keymap) == -1) + buf = NULL; } else { #ifndef WIN32 @@ -350,12 +353,13 @@ char tmpname[PATH_MAX]; #else char *xkmfile = tmpname; #endif - buf = Xprintf( + if (asprintf(&buf, "xkbcomp -w %d -xkm \"%s\" -em1 %s -emp %s -eml %s \"%s%s.xkm\"", ((xkbDebugFlags<2)?1:((xkbDebugFlags>10)?10:(int)xkbDebugFlags)), xkmfile, PRE_ERROR_MSG,ERROR_PREFIX,POST_ERROR_MSG1, - xkm_output_dir,keymap); + xkm_output_dir,keymap) == -1) + buf = NULL; } #ifdef TEST -- cgit v1.2.3 From 3965f24befb21f469b887d4c69b9defc861831fb Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 1 Nov 2018 13:29:16 +0100 Subject: adapt code-versions.txt --- nx-X11/programs/Xserver/code-versions.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nx-X11/programs/Xserver/code-versions.txt b/nx-X11/programs/Xserver/code-versions.txt index 5a09d89ea..fe8938895 100644 --- a/nx-X11/programs/Xserver/code-versions.txt +++ b/nx-X11/programs/Xserver/code-versions.txt @@ -19,4 +19,4 @@ render 6.9/7.0 Xext 7.1/1.1 xfixes 1.4.2 Xi 1.3.0.0 -xkb 7.1/1.1 +xkb 1.3.0.0 -- cgit v1.2.3